[英]Android/sencha/phonegap ajax call to local php file returns whole code?
只是想知道是否有人在这里给我一点支持。 我正在使用phonegap在android手机上运行sencha应用程序。 在代码中,我正在对本地存储的php文件进行ajax调用,以检查文件是否存在……
myRequest = Ext.Ajax.request({
url: 'resources/phpScripts/poifound.php',
method: 'GET',
params: {
pakname: packname,
poiident: poiid
},
success: function(response) {
console.log(response.responseText);
},
failure: function(response) {
console.log("failed");
}
});
和PHP文件...
<?php
$pakname = $_GET["pakname"];
$poiid= $_GET["poiident"];
if (!file_exists('../../packages/' . $pakname .'/poisfound/' . $pakname . $poiid . '.txt')) {
return "false";
}
else {
return "true";
}
?>
它实际上不是在LogCat中记录“ true”或“ false”,而是在记录整个php代码。 在chrome中运行sencha应用时,它会通过回显而不是return来返回“ true”或“ false”。 任何帮助将不胜感激。
那是因为,您将PHP文件打包到android设备上。 android上没有PHP解释器。 您将需要一个运行PHP的服务器。
myRequest = Ext.Ajax.request({
url: 'http://myserver.com/resources/phpScripts/poifound.php',
method: 'GET', [...]
为了使您的生活更轻松,您需要将服务器添加到白名单中: http : //docs.phonegap.com/en/2.4.0/guide_whitelist_index.md.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.