Ext js 中的代理返回错误语法错误:预期的表达式,得到'<'



我是Extjs的新手。我有一个测试.js.php页面,其中一部分,有Ext.data.Store

this.store2 = new Ext.data.Store({
fields : ["Pid","bid"],
proxy : {
type: 'jsonp',
url:  '../d/sample.data.php?task=GetUser',
reader: {
root: 'rows',
totalProperty: 'totalCount'
}
}
});

而在../d/sample.data.phppage 我在夏天有这个:

$task = isset($_POST ["task"]);
if($task == "GetUser")
GetUser();

function GetUser() {
$dt = array();
$dt = array_merge($dt, Pdo::runquery("select PID , bid from mytable where PID  = ? ", array($_SESSION['PID'])));
echo dataReader::getJsonData($dt, count($dt), $_GET["callback"]);
die();
}

这些代码在站点中运行良好,但在我的虚拟主机中运行不行。当我在本地主机中运行时,在控制台中收到以下消息:语法错误:预期的表达式,得到"<">,它引用 sample.data.php:1

我在下面尝试/var/www/myVirtualHostName 中的所有文件:

chmod 777 -R ./* 

附言: 我正在使用 ubuntu 20.04、虚拟主机、php5.6 和 apache2

为什么需要 jsonp 代理?在这种情况下,最好将标准 AJAX 代理与 JSON 读取器一起使用。像这样:

this.store2 = Ext.create('Ext.data.Store', {
fields : ["Pid","bid"],
proxy : {
type: 'ajax',
url:  '../d/sample.data.php?task=GetUser',
reader: {
type: 'json',
root: 'rows',
totalProperty: 'totalCount'
}
}
});

JsonP 用于跨域请求。

最新更新