Jquery Ajax Return Readystate 1 Or Incorrect Data Type
I write script for Wordpress plugin and have problem with ajax response. When i want get json file, jQuery.ajax return {readyState: 1}. jQuery.ajax with async: false return plain t
Solution 1:
Ajax call returns promise so you have to use done
menthod to work with result, for example:
function GetJsonLanguageFile(url, lang) {
return $.ajax({
url: url,
type: 'POST',
dataType: 'json',
// async: false,
data: {action:'adminajax',method:'GetJsonLanguageFile',language: lang},
});
}
GetJsonLanguageFile('some.url', lang).done(function(data) {
// if it returns string insted of JSON try it:
data = $.parseJSON(data);
// do rest
// window.json = data;
});
Post a Comment for "Jquery Ajax Return Readystate 1 Or Incorrect Data Type"