无法在ajax调用中进行window.location.reload()
问题
我无法使用 window.location.reload() 刷新页面,该页面在对 yahoo 的成功调用中使用。
任何提示如何修复它。 整个代码工作正常,它正在调用 cse 服务器,从那里获取内容,保存在雅虎上。但我必须手动刷新页面才能显示内容。我希望它是自动的,所以我使用了 window.location.reload() 但这不起作用。任何建议如何完成。下面的函数实际上是一个按钮的函数。
Problem
I am not able to refresh the page with window.location.reload() which is used inside the success call made to yahoo.
Any hints how it can be fixed.
The whole of the code is working fine it is making call to cse server getting contents from there saving on yahoo. but i have to manually refresh the page to bring the contents. I want it to be automatic so I used window.location.reload() but thats not working. Any suggestions how it can be done. The function below is actually a function for a button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是问题所在。
如果您的脚本从 CSE 服务器的域运行,则无法将数据发送到 yahoo 服务器。这是 javascript 的主要限制。同样,如果在 yahoo 域之外运行,您可以向其发送数据,但无法向 CSE 服务器发送数据,除非它是 yahoo 域的一部分。
会起作用:
从 blahblahblah.yahoo.com 获取数据,然后将数据发送到 somedomain.yahoo.com
不起作用:
从 blahblahblah.somesite.com 获取数据并将数据发送到 somedomain.yahoo.com
要点,如果您从“csce.unl.edu”获取数据并运行该域(也称为在浏览器窗口中运行脚本)该域),您只能将数据发送到以“.unl.edu”结尾的站点。因此,您可以从“test.unl.edu”发送或接收,但不能从某些雅虎网站发送或接收。
解决方案:
在某个网络服务器上托管代理脚本,或者用 PHP 编写所有代码。这是关于代理脚本是什么的两个很好的参考,第二个链接实际上为您提供了一个:
链接 1
链接 2
需要更多帮助,您可以告诉我,我必须设置一个我自己在我的服务器上启动,如果您遇到问题,我可以帮助您。
That's the problem, right there.
If your script is running from the CSE server's domain, you cannot send data to the yahoo server. This is javascript's main limitations. Likewise, if running off of the yahoo domain, you can send data to it, but cannot send data to the CSE server, unless it is part of the yahoo domain.
Would work:
Get data from blahblahblah.yahoo.com, then send data to somedomain.yahoo.com
Would not work:
Get data from blahblahblah.somesite.com and send data to somedomain.yahoo.com
Main point, if you're getting data from "csce.unl.edu" and running off of that domain (aka running your script in a browser window from that domain), you can only send data to a site that ends with ".unl.edu". So you can send or receive from "test.unl.edu", but not some yahoo site.
A solution:
Host a proxy script on some webserver, or write all of your code in PHP. Here is two great references on what a proxy script is, and the second link actually provides one for you:
Link 1
Link 2
Any more help needed, you can let me know, I had to set one up myself, on my server, and I can help you out if you run into problems.
你试过吗:
did you tried: