我的codeigniter网站有一个奇怪的错误。所有echo json_encode语句在参数之前都有一个s +回车字符串,由于未定义的格式而停止触发成功事件,并且在我从php发送的html文本之前还有s +回车符。是否有人在此之前遇到过这样的错误,或者知道在哪里寻找或如何纠正它?
这是chrome中的错误输出:
DEPENDENCY
<exception>: SyntaxError: Unexpected token s
message: "Unexpected token s"
stack: "SyntaxError: Unexpected token s
at Object.parse (native)
at e.extend.parseJSON (/js/site/jquery-1.7.1.min.js:3:11020)
at cc (/js/site/jquery-1.7.1.min.js:3:1382)
at w (/js/site/jquery-1.7.1.min.js:7:11263)
at XMLHttpRequest.f.support.ajax.f.ajaxTransport.send.d (/js/site/jquery-1.7.1.min.js:7:17218)"
get stack: function () { [native code] }
set stack: function () { [native code] }
__proto__: Error
b: "s
{"status_code":1,"message":"welcome"}"
&#13;
function signin(){
var signin_email = $('#signin_email_address').val();
var signin_password = $('#signin_password').val();
if(signin_email==''){
alert('Please enter the email address');
}else if(signin_password==''){
alert('Please enter the password');
}else if(signin_password.length < 6){
alert('Password must be minimum of 6 characters');
}
else {
var remember = 'no';
if($('#remember').is(':checked')){
remember = 'yes';
}
$.ajax({
type: 'POST',
url: baseURL+'site/user/login_user',
data: {"email":signin_email,"password":signin_password,"remember":remember
},
dataType: 'json',
success: function(json){
if(json.status_code == 1){
window.location.reload();
}else{
alert(json.message);
}
}
});
}
return false;
}
&#13;