带有phonegap的ajax请求
我试图向phonegap内的本地主机中的某个网站发出AJAX请求,但它不起作用,我只是失败了,我尝试了很多方法,但什么也没发生
,当我尝试使用phonegap的一些本地文件执行此操作时100%工作
我已经读到它的跨域问题,所以我尝试了jSONP,但没有什么可能是模拟器或phonegap的问题,或者也许有一种特定的方法可以做到这一点,
请帮助
过的解决方案之一
$.ajax({
url: "http://127.0.0.1/test/index.php",
type: "POST",
dataType: "json",
success: function(msg){
alert(msg);
}
}
)
这是我尝试 使用 DW 5.5 模拟它并且它正常工作我如何在 Eclipse 上修复这个问题
I was trying to make AJAX request to some website in the localhost within phonegap but it's not working and I got just failure and i tried a lot of ways to it but nothing happened
and when I try doing it with some local file for the phonegap it works 100%
I have read that its cross domain problem so I tried jSONP and nothing it could be a problem from the emulator or phonegap or maybe there is a specific way to do it
Please Help
this is one of the solutions I tried
$.ajax({
url: "http://127.0.0.1/test/index.php",
type: "POST",
dataType: "json",
success: function(msg){
alert(msg);
}
}
)
I tried emulating it using DW 5.5 and its worked normally how can i fix this on eclipse
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将 url: "http://127.0.0.1 更改为运行 php 服务器的 PC 的 IP 地址。在 MacOS 和 Linux 上,ifconfig 命令会告诉您 IP 地址。获取该 IP 地址并替换//127.0.0.1 在你的源中。
You need to change url: "http://127.0.0.1 to the IP address of the PC where the php server is running. On MacOS and Linux, the ifconfig command will tell you the IP address. Get that IP address and replace the //127.0.0.1 in your source.
是的palcoder....我也有这个问题...花了一整天才找到问题。
罪魁祸首是 Eclipse... 经过多次检查和试用后,我发现
在本地计算机上运行将不允许 ajax jsonp 进程执行。您应该使用
不同的域...它就像一个魅力...
希望有人不要像我一样在本地主机上浪费时间。 :)
yes palcoder.... I have this issue too... it has taken a whole day to find the problem.
Its the eclipse who is the culprit... After so many times checking with hit and trial I came to know
that running on localmachine will not allow the ajax jsonp process to execute. You should use a
different domain... and it works like a charm...
Hope some one doesn't waste time on localhost just like me. :)