Answer the question
In order to leave comments, you need to log in
Ajax ( json ) throws error about unknown character, how to get only response from php without tags?
Here is the ajax itself:
var filters_form = jQuery('#filters_form');
var filter_search_form = jQuery('#filter__search-form');
var form_handler_url = filters_form.attr('action');
var form_method = filters_form.attr('method');
var form_data = jQuery('input', filters_form).serialize();
var data_type = 'json';
jQuery('input', filters_form).on('change', function(){
jQuery.ajax({
type: form_method,
url: form_handler_url,
data: form_data,
dataType: data_type,
success: function ( response ){
var responseData = JSON.parse(response);
console.log(responseData);
},
error: function ( xhr, ajaxOptions, thrownError ) {
console.log('Sorry, you have an error in you require!');
console.log(thrownError);
console.warn(xhr.responseText);
}
});
});
return json_encode('Hello');
<?php return json_encode('Hello');?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question