
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 展开
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 展开
1个回答
展开全部
json parse错误吧,php中把echo $strquery;注释掉。因为打印这个,所以把返回结果转成JSON的时候出错。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询