jquery AJAX and json format

前端 未结 4 1408
有刺的猬
有刺的猬 2020-11-30 09:00

I have a webservice that expects to receive json, like so:

{\"first_name\":\"test\",\"last_name\":\"teste\",\"email\":\"moi@someplace.com\",\"mobile\":\"+44          


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 09:16

    Currently you are sending the data as typical POST values, which look like this:

    first_name=somename&last_name=somesurname
    

    If you want to send data as json you need to create an object with data and stringify it.

    data: JSON.stringify(someobject)
    

提交回复
热议问题