I got some problem in JSONP result can somebody give me the idea how to reformat the JSONP .responseText result into correct JSON format.
var result = ''
$.fn.ajaxUse = function(fullurl){
result = $.ajax({
dataType: 'jsonp',
data: 'id=test',
jsonp: 'callback_jsonp',
url: fullurl,
success: function(data){},
error: function(xhr){
alert(xhr.responseText);
},
async: false
}).responseText;
}
$.fn.ajaxUse(ajaxurl+'menu.php');
alert(result);
When I use the above code and try to return JSON result I got the result as follow. Can somebody answer me how can I parse the result in JSON format, I use parseJSON already and not working. I would like to remove jQuery17018127539248006552_1322568664691 from following result and would like to get correct JSON only.
jQuery17018127539248006552_1322568664691({"lang":{"1":"Organization Information","2":"Project List","3":"Project Details","4":"Advanced Search","5":"Layers List"}});
I think
resultis getting set to the return value of yourajaxUsefunction rather than the JSON that gets returned from your URL. Try –