更新时间:2023-08-24 14:47:22
I answered a similar question here: Sencha seems to not like Rails' json. It is specific to Rails but the concept still applies.
基本上詹姆斯·皮尔斯是正确的.您返回的内容需要包装在标记和回调函数中.这将在页面上插入代码并运行脚本,从而具有调用您提供的功能的作用.
Essentially James Pearce is correct. What you are returning needs to be wrapped in a tag and the callback function. This will insert the code on your page and run the script, which has the effect of calling the function you provide.
$response = "<script type='text/javascript'>";
$response .= $_GET['callback'] . "(" . json_encode($row) . ")";
$response .= "</script>";
$this->output->set_content_type('application/json')->set_output($response);