Posting JSON with JQuery

后端 未结 2 1185
走了就别回头了
走了就别回头了 2021-01-01 05:10

Trying to get JQuery to post JSON to a server:

$.ajax({  
  url: \"/path/to/url\",  
  type: \"POST\",  
  dataType: \"json\",  
  contentType: \"json\",  
          


        
2条回答
  •  天涯浪人
    2021-01-01 05:53

    Datatype is for returned data. Contenttype is not applicable, see here

    It can only send strings, I use JSON.stringify on my created javascript objects, in your case you could just manually code the string.

    You will also need to access the string on server side, for that if you are using java I can recommened google's gson

提交回复
热议问题