During my coding in JavaScript, I used to initialize an array like this:
var data = new Array();
data['id'] = self.iframeFields.id.val();
data['name'] = self.iframeFields.name.val();
data['location'] = self.iframeFields.location.val();
data['about'] = self.iframeFields.about.val();
data['company'] = self.iframeFields.company.val();
data['website'] = self.iframeFields.website.val();
However, when trying to pass var data
, it returns a null value.
Surprisingly, data['id']
does return a value.
I'm left wondering what mistake I made in my code.
UPDATE: Upon reading nrabinowitz's response, I noticed that I had the following line of code:
if ($.isArray( data )){ ajax({
url: myurl,
data: {
method: "updateProfile",
data: data
},
normalizeJSON: true,
success: function( response ){
// Check to see if the request was successful.
if (response.success){
alert(response);
} else if (onError){
// The call was not successful - call the error function.
alert(response);
}
}
});
}
Since 'data' is actually an object and not an array,
it wasn't returning anything.
By removing the following block of code:
if ($.isArray( data )){ }
the issue was resolved.