Code: Select all
$.ajax({ url: '/ajax-search.php',
data: {action: 'test'},
type: 'GET',
success: function(output) {
alert(output);
}
});Moderator: General Moderators
Code: Select all
$.ajax({ url: '/ajax-search.php',
data: {action: 'test'},
type: 'GET',
success: function(output) {
alert(output);
}
});Not sure what line of code you're looking for. If you go back to the original jQuery with the AJAX call in it, where does that leave things?simonmlewis wrote:Sure. But what is the "line of code" I had to pop in, and where.... so I can see if it works this end?
Code: Select all
<script>
// This really belongs in a separate JS file, not embedded alongside PHP or HTML
$(document).ready(function() {
$('.home-search-input input').on('keyup', function(event) {
var search_string = $(this).val();
// Don't fire on very short strings
if (search_string.length > 2) {
var category = $('.home-search-cat select').val();
$.ajax({
url: '/ajax-search.php?search=' + search_string + '&category=' + category,
method: 'GET'
}).done(function(response) {
$('#txtHint').html(response);
});
}
});
$('.home-search-cat select').change(function(event) {
var category = $(this).val();
var search_string = $('.home-search-input input').val();
$.ajax({
url: '/ajax-search.php?search=' + search_string + '&category=' + category,
method: 'GET'
}).done(function(response) {
$('#txtHint').html(response);
});
});
});
</script>