Why is there no serialize to JSON in jQuery? [closed]
Hi a couple of days ago I had to post a js object to the server via ajax and I discovered there was no way to convert an object to JSON using jQuery.
So it's really a two part question: 1. Why is a toJSON() method not included in jQuery and 2. what is the best way to post a js object to the server?
Cheers,
Joe
normally you dont pass JSON but you serialize your data, hence the .serialize()
it's normally the server that sends json... not the client.
the best way is to serialize the object.
http://api.jquery.com/serialize/
精彩评论