Then before I pass the customer object parameter to my WCF service through a jQuery ajax() function call I "stringify" the object using Douglass Crockford's json2.js lib (https://github.com/douglascrockford/JSON-js) - JSON.stringify(customer) - and this works successfully.
I just wanted to find out if this is the standard way that most developers are doing this these days and is there a function built into jQuery that does the same thing (seems like there should be)? Thanks!
Well - the web service is an ajax-enabled wcf service so the request must be in JSON.
Basically, I'm just wondering if there are any better ways, especially built into jQuery.
The jquery ajax function can handle translation for primitive parameters like string and int but the jQuery ajax function does not seem to handle object conversions like the one provided in my original example, at least in my own local test....
I think I tried to comment out the script ref to Crockford's json2.js and call JSON.stringify(myObj) without the script ref but I got a js error. It looks like a second "replacer" parameter may be required. Should I pass null for the second "replacer" parameter or is an actual value required for the "replacer" parameter?
I did a little more Googling and although the native JSON.stringify works well in FireFox it tends to have issues in IE. I ran my local test with JSON.stringify(myObject) in FireFox without issue but I get the error: "'JSON' is undefined" in IE. It feels safer to simply reference Crockford's JSON.stringify implementation for now because I have used it on several projects and I know that it works without issues....