jQuery数值传递问题

环境:apache2.4.4jquery-1.6.1.min.js前台java代码:<scripttype="text/javascript">varcurPage=1;... 环境:apache2.4.4
jquery-1.6.1.min.js
前台java代码:
<script type="text/javascript">
var curPage = 1;
var totalRecords,pageSize,totalPages;
var strsql = "select * from op_record order by time desc";

function getData(page){
$.ajax({
type: 'POST',
url: 'pageshow.php',
data: {'pageNum': page-1, 'strQuery': strsql},
dataType: 'json',
........
error:function(xhr,textStatus,excep){
alert(xhr.statusText);
alert(xhr.responseText);
alert(xhr.status);
alert(excep);
}
........
前台php代码:
<?php
header('content-type : text/html; charset=utf-8');
@$page = intval($_POST['pageNum']);
@$strquery = $_POST['strQuery'];

$strsql = json_decode($strquery);
echo $strquery;
..........
echo json_encode($arr);
?>
出错返回:
xhr.statusText 显示 parsererror
xhr.responseText 显示select * from op_record order by time desc{arr数组内容(经测试正确)}
xhr.status显示200
excep显示SyntaxError:Unexpected token s

请求帮助,问题是出在strsql的传递上,如果不传递strsql一切OK
展开
 我来答
zhaoapk
2014-01-17 · TA获得超过3771个赞
知道大有可为答主
回答量:1343
采纳率:40%
帮助的人:1660万
展开全部
json parse错误吧,php中把echo $strquery;注释掉。因为打印这个,所以把返回结果转成JSON的时候出错。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式