Please Visit: http://ift.tt/1ajReyV
from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1kEGrYW
via LifeLong Community
Sending FormData with jQuery.ajax() | Matt
Unfortunately, it’s not as easy as setting the data attribute to the FormData instance; jQuery runs anything that isn’t a string through (Link->http://ift.tt/1mfGh8E) to serialize the objects keys into key1=a&key2=b etc; running FormData through this doesn’t end too nicely.
However one of jQuery.ajax()‘s many options is processData, which allows you to turn off this behaviour by setting it’s value to false. So, to use FormData with jQuery.ajax() it’s as simple as:
var formData = new FormData($('form')[0]); // Create an arbitrary FormData instance
jQuery.ajax('/endpoint.php', {
processData: false,
contentType: false,
data: formData
});
http://ift.tt/1kEGrYT
http://ift.tt/1mfGh8G
Unfortunately, it’s not as easy as setting the data attribute to the FormData instance; jQuery runs anything that isn’t a string through (Link->http://ift.tt/1mfGh8E) to serialize the objects keys into key1=a&key2=b etc; running FormData through this doesn’t end too nicely.
However one of jQuery.ajax()‘s many options is processData, which allows you to turn off this behaviour by setting it’s value to false. So, to use FormData with jQuery.ajax() it’s as simple as:
var formData = new FormData($('form')[0]); // Create an arbitrary FormData instance
jQuery.ajax('/endpoint.php', {
processData: false,
contentType: false,
data: formData
});
http://ift.tt/1kEGrYT
http://ift.tt/1mfGh8G
from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1kEGrYW
via LifeLong Community
No comments:
Post a Comment