<?php/* Recently done an AJAX validate form validation submitted code, when the AJAX submission JS request error: unexpected token T in the JSON at position 0 Description: This is a request, the parameters of the local newspaper this is the wrong, Excuse me, why? Best of all. Solution 1: To see the JSON format requirements, the Json.parse () method for JSON string requirements very strict solution 2:http://www.bejson.com/use this URL to test the JSON format is not wrong, line, Single quotation mark what will cause an error, the format requirements are very strict the following results in an error: the non-numeric key value in the JSON string does not have a tab in the double quotation mark JSON, which looks like a space, but is because its existence check does not pass. get rid of it. The editor has a BOM header that also causes Solution 3: A json.parse is used somewhere, but the passed-in parameter is not a qualified JSON string. The above describes the "(JavaScript) JS request error: unexpected token T in the JSON at position 0" problem answer, I hope to have the need to help users. *//***JS Ajax Send Code */$.validator.setdefaults ({submithandler:function () {///alert ("Commit event!"); return false; var query=new Object (); query.user_name=$ (' #user_name '). Val (); query.sex=$ (' #sex '). Val (); query.country=$ (' #country '). Val (); query.email=$ (' #email '). Val (); query.mobile=$ (' #mobile '). Val (); query.weixin=$ (' #weixin '). Val (); query.address=$ (' #address '). Val (); query.messages=$ (' #messages '). Val (); var url= "/controller/apply.php"; $.ajax ({ Url:url, type: "POST", Data:query, DataType: "JSON", Success:function (res) { if (res.status==1) {alert (res.msg); Window.location.replace ("http://www.fxbob.com/a/zhongwen/hezuohuoban/20170620/21.html"); }else{alert (res.msg); }}, Error:function (XMLHttpRequest, Textstatus, Errorthrown) {Console.log (xmlhttpreques T); Console.log (Errorthrown); alert (xmlhttprequest.status); alert (xmlhttprequest.readystate); alert (textstatus);},complete:function (XMLHttpRequest, textstatus) {this;//The options parameter passed when calling this Ajax request}}); return false; }});/***php's Ajax receive code apply.php as follows: */<?php//Header ("content-type:text/html; Charset=utf-8 ");d efine (' Dedemob ', ' Y '); require_once (DirName (__file__)." /.. /include/common.inc.php ");//Load Message Class require_once (DirName (__file__)." /.. /include/smtp.class.php "), if ($_post) {$datA=$_post, $str =<<<eotJS Request Error: unexpected token T in JSON at position 0