微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

关于如何处理JavaScript小部件的想法?

我的朋友有一个搜索引擎,他希望有一个小部件访问权限,可以放在其他网页上.如果我向搜索引擎发送请求,它将返回一个XML文件.请求看起来像这样:
    http://www.site.com/page.php?keyword=this+is+a+sample&page=1&num_days=3&source_id=site2.com&source_name=site2&source_url=sampleurl.php

我了解如何使用Javascript访问它.但是,我知道你不能做跨域请求.我必须让它在搜索引擎的网站上加载一个页面,而不是在他们所在的网站的窗口中….对吗?非常感谢任何想法或见解.

解决方法:

这也是一个很好的解释:

What is JSONP all about?

编辑:

jsonpString

Override the callback function name in
a jsonp request. This value will be
used instead of callback in the
callback=? part of the query string
in the url. So {jsonp:'onjsonPLoad'}
would result in ‘onjsonPLoad=?’ passed
to the server.

jsonpCallbackString

Specify the callback function name for
a jsonp request. This value will be
used instead of the random name
automatically generated by jQuery. It
is preferable to let jQuery generate a
unique name as it’ll make it easier to
manage the requests and provide
callbacks and error handling. You may
want to specify the callback when you
want to enable better browser caching
of GET requests.

取自:
http://api.jquery.com/jQuery.ajax/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。