显示jquery jsonp回调结果
抱歉,我的问题愚蠢而基本......
如何将 jsonp 回调结果写入页面,我正在尝试使用 jquery 但结果 - 数据已保存:[object Object]
function alertResponse(text) {
document.write( "Data Saved: " + text );
}
$.ajax({
url: URL,
dataType: 'jsonp',
jsonpCallback: 'alertResponse'
});
url 的结果是
jsonp1293628807768({"text":" <div class=\"package_search_result_table\" 710px>\r\n <div class=\"itt_title\" style=\"width: 710px;\">\r\n
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 <div class=\"itt_title\" style=\"width: 710px;\">\r\n
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
jsonpCallback 是一种了解处理回调的函数名称的方法。它不应该是回调函数!您应该尝试
complete:alertResponse
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
您可以使用 JSON 库及其
JSON.stringify
函数来显示文本。You can use JSON library and it's
JSON.stringify
function to display the text.如果您希望 jQuery 调用特定函数,则必须添加
jsonp: false
。只写jsonpCallback
是没有用的If you want jQuery to call a specific function you must add
jsonp: false
. Writing onlyjsonpCallback
is useless