jQuery(document).ready(function($) {
$("button").click(function(event) {
var formData = new FormData($("-sharpformdata")[0]);//[0]
event.preventDefault();
$(function(){
$.ajax(
{
type:"post",
url : "http://test2.com/formdata.php",
data:formData,//
cache: false,
contentType: false,
processData: false,
dataType:"json",
success : function(data) {
var html = "<div>:"+ data.user+"</div>";
html += "<div>:"+ data.pass+"</div>";
$("-sharpshowTips").html(html);
},
}
);
});
});
});
when submitting a form using formdata, if the above code is changed to
var formData = new FormData($("-sharpformdata"))
will report an error, and all form key-value pairs are not defined. This means that the form form was not fetched. Why is that? Please say the principle, not the title