Server unable to parse a valid json

后端 未结 1 1530
不知归路
不知归路 2021-02-14 08:50

I am making this ajax request to a url, but server is sending a response Unrecognized token \'naejzraieale\': was expecting \'null\', \'true\', \'false\' or NaN at [Sourc

相关标签:
1条回答
  • 2021-02-14 09:23

    before sending data to server you need to encode it in JSON format JSON.stringify and JSON.parse are provided by latest browsers but if any browser doesn't support that then you can use a jquery plugin to do the same http://code.google.com/p/jquery-json/, if you use this plugin then the syntax would be different a little bit

    $.ajax({
           url: "https://jsonparser.mydomain.com",
           type: 'POST',
           contentType:'application/json',
           data: JSON.stringify({name : "juzer ali",
                   email : "email@gmail.com",
                   how : "Used jQuery.ajax from google chromes developer console",
                   urls : ["https://chrome.google.com/webstore/search/",                                  "https://chrome.google.com/webstore/detail/", 
    "https://github.com/", "https://docs.google.com/document/d/edit?pli=1", "pro.appspot.com"]}),
           dataType:'json'
    });
    
    0 讨论(0)
提交回复
热议问题