I am trying to insert an key/value pair into a serializeArray(from jquery).
So I have something like
var form = $('#form');
var sendFormData = form.serializeArray();
sendFormData.push({ "name": "Name", "value": "test"});
In firefox this works yet in IE 8 I get
Line: 51 Error: Object doesn't support this property or method
So it seems to be pointing to this line. So does ie 8 not support push if so what is a way I can add a key/value pair that will work in all browsers(the 5 mains ones firefox, ie8, chrome, opera, safari)
What you have works (even in IE8), you can test it here: http://jsfiddle.net/ZAxzQ/
There must be something outside the question that you're doing to get that error :)
.push()
has been around as long as the Array object, I've never seen a browser that doesn't support it...your unsupported error has to be coming from something else.
This is not an exhaustive answer as it won't solve your problem, but the Array.push()
method works in IE8:
var arr = [];
arr.push({ "name": "Test Name", "value": "Test Value"});
alert(arr[0].name); // Displays "Test Name"
The above can also be re-written as follows:
var arr = [];
arr[arr.length] = { "name": "Test Name", "value": "Test Value"};
alert(arr[0].name); // Displays "Test Name"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With