I am trying to catch another value from AJAX but it is giving me an error Uncaught TypeError: e.replace is not a function.
Here is my code.
source: function(name, response) {
$.ajax({
type: "GET",
dataType: "json",
url: af_vars.af_ajax_url,
data: "action=get_listing_names&name=" + name,
success: function(data) {
// response(data);
var tickers = [];
$.map( data, function( item ) {
for (var index = 0; index < item.length; index++) {
tickers.push(item[index]['tickers']);
}
});
console.log(tickers);
response(tickers);
},
error: function(response) {}
});
},
onSelect: function(e, term, item) {
//my code
}
and here is my PHP ajax request code
$titles = array();
if (!empty($results)) {
foreach ($results as $term) {
$data = array();
$data['tickers'] = get_term( $term->parent, 'exchange' )->name ? esc_attr( get_term( $term->parent, 'exchange' )->name ) .' : '. addslashes($term->name) : addslashes($term->name) ;
$data['isArchived']= get_term_meta( $term->term_id , 'ticker_archived', true) == 1 ? 'true' : 'false';
$titles[] = $data;
}
}else {
$titles[] = "No results found";
}
echo json_encode(array(
'results' => $titles
)
);
So, I want to show tickers in dropdown and want isArchive result as hidden value to pass along with tickers in onSelect
from Get value in onSelect which is selected in autocomplete
No comments:
Post a Comment