Show jquery jsonp callback result
Sorry as my question stupid and elementary....
how write jsonp callback result to page, I'm trying such with jquery but result - Data Saved: [object Object]
function alertResponse(text) {
document.write( "Data Saved: " + text );
}
$.ajax({
url: URL,
dataType: 'jsonp',
jsonpCallback: 'alertResponse'
});
the rusult by url is
jsonp1293628807768({"text":" <div class=\"package_search_result_table\" 710px>\r\n &l开发者_StackOverflow中文版t;div class=\"itt_title\" style=\"width: 710px;\">\r\n
jsonpCallback is a way to know the name of the function that will handle the callback. It's not supposed to be the callback function! You ought to try complete: alertResponse
You can use JSON library and it's JSON.stringify
function to display the text.
If you want jQuery to call a specific function you must add jsonp: false
. Writing only jsonpCallback
is useless
$.ajax({
url: URL,
dataType: 'jsonp',
jsonp: false,
jsonpCallback: 'alertResponse'
});
精彩评论