I have seen that when using $ .post () in jquery that the default contentType application / x-www-form RELCODE - When there should be contentType = application / json
in my asp.net mvc code (why should I see this question that I should use application / jsan):
How can I send $ .post () contentType = application / json? I already have a large number of $ .post () functions, so I do not want to change to $ .jax () because it will take a lot of time
if I try
< Previous> $ Post (url, data, function (), "json")
There is still contentType = application / x-www-form-urlencoded. So what does "JSON" do the best if it does not change the content type in JSN?
If I try
$ Ajaxsetup ({contentType: "application / json; charset = utf-8"});
It works, but I have $$ every $ And affects $ .post and causes some to break
So what is the way that I can change the behavior of $ .post () to send content.Type = application / json Can i
I think you could
be 1. to create the source $ Edit .post always use the JSON data type because it is actually only a shortcut for the pre configured $. Ajax
call
or
2.
or
3.You can punch the monkey With its own implementation through $ Post Function
can overwrite.
In your example, JSON refers to the datatype datatype to is not the format sent on the server and server.
Comments
Post a Comment