显示jquery jsonp回调结果

发布于 2024-10-10 01:59:37 字数 479 浏览 0 评论 0原文

抱歉,我的问题愚蠢而基本......

如何将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酒解孤独 2024-10-17 01:59:37

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

人事已非 2024-10-17 01:59:37

您可以使用 JSON 库及其 JSON.stringify 函数来显示文本。

You can use JSON library and it's JSON.stringify function to display the text.

疧_╮線 2024-10-17 01:59:37

如果您希望 jQuery 调用特定函数,则必须添加 jsonp: false。只写jsonpCallback是没有用的

$.ajax({
    url: URL,
    dataType: 'jsonp',
    jsonp: false,
    jsonpCallback: 'alertResponse'
});

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'
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文