Request Media Type[application/json] Error! Request Body is not JSON format issue for Extjs Ajax request -


i using extjs 5.1.3. have post request params as-

{"root":{"countryid":"458","ruleid":"3386","rulename":"test1 \\","ruletype":"cell_store","optype":"details"}} 

i creating ajax request as-

  ext.ajax.request({                        method: 'post',                        url: appurl.fetchruledetails,                        params: win.jsondata,                        callback: function(option, success, response){                            })                    }) 

from server side, response coming as-

{   "rules":[     {       "countryid":"458",       "ruleid":"3386",       "rulename":"test1 \\",       "ruletype":"cell_store",       "ruleparts":[         {           "seq":"1",           "attrid":"6",           "attrname":"store type",           "op":"=",           "val":"dsafdaf",           "chartype":"global_char"         }       ]     }   ],   "status":{     "statusflag":true,     "statuscode":"success",     "statusmessage":"success"   } } 

but in ajax request's callback function, receiving response.responsetext as- request media type[application/json] error! request body not json format.

my guess issue because of rulename value "test1 \". can please me whats missing.

the error message not extjs error message. if receive extjs error related invalid json, this:

uncaught error: you're trying decode invalid json string: testtest

my best guess error message comes server, because expects send request json. right sending formdata. send request json, have put object in jsondata config , leave params config undefined:

ext.ajax.request({     method: 'post',     url: appurl.fetchruledetails,     jsondata: win.jsondata,     callback: function(option, success, response){     }) }) 

for future questions regarding server-client communication, please keep in mind should first check in browser network tab send server , response server is.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -