i have a javascript object declared something like:
var myObject = {"a":{"b": "c", "d": "e"}, "f":{"g":{}, "h":{}}};
I’m using jQuery’s
$.post(url, myObject, function(){});
to send the data to my php file. for some reason, the empty properties are not being passed, so, because “g” and “h” are empty, even “f” is not passed in the post.
Is there any way i can include them without filling it with bogus data?
thanks
I think that your problem is not with JavaScript. When you call “$.post()” like that, your object will be turned into a HTTP query form with the equivalent of “$.param”:
That string looks like:
which, decoded, is:
edit — well that’s odd. Internally, jQuery is indeed setting up the parameters as I wrote above, but for whatever reason Firefox is stripping out the empty ones. If I add a “beforeSend” handler, it’s clear that the parameters are all there, those with values as well as those without. However, when the actual HTTP request goes out, they’re gone.
You could attach the parameters to the URL if you don’t mind them going out on the wire that way.