jquery.load()没有在phonegap上工作 [英] jquery.load() not working on phonegap

查看:81
本文介绍了jquery.load()没有在phonegap上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发带有phonegap的买家指南应用程序。我试图从服务器使用jquery获取一些信息。但当我使用phonegap运行以下代码时它无法正常工作

I am developing buyers guide app with phonegap. where i am trying to fetch some info from server using jquery. but when i run following code with phonegap its not working

<!DOCTYPE html>
<html>
<head>
<script src="jquery-1.9.1.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $('#div1').load('http://localhost/MySample.php');
  });
});
</script>
</head>
<body>

<div id="div1"><h2>Click to get information</h2></div>
<button>Get External Content</button>

</body>
</html>


推荐答案

您是在模拟器上还是在设备上进行测试?

Are you testing on simulator or on a device?

您不能在设备上使用localhost,因为localhost是设备,您必须使用服务器本地IP

You can't use localhost on a device because localhost is the device, you have to use the server local IP instead

你必须将IP列入白名单(或使用*,它将所有IP列入白名单)
白名单指南

And you have to whitelist the IP too (or use *, it whitelist all the IPs) whitelist guide

这篇关于jquery.load()没有在phonegap上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆