0

i'm designing a web interface using only xhr functions for forms processing while it's working perfectly on chrome, it has a very weird behavior on IE and firefox: not all datas are transmisted when submiting a form and there is nothing pointing to something specific when these errors occurs.

my post function looks like this:

function submitForm(formName,formTarget)  {
console.log(formName);
var form = document.getElementById(formName);
var formDatax = new FormData(form);

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
document.getElementById("mainCenter").innerHTML = xhr.responseText;
} else if (xhr.readyState < 4) {
document.getElementById("mainCenter").innerHTML = "<div class='loadingDiv'></div>";
}
};
xhr.open('POST', formTarget, true);
xhr.send(formDatax);

return false;
}

some forms are sent correclty, some others not (even very simple, like email/password login form)!

did anybody encoutered the same behavior or any clue to correct this ?

thank you !

4

1 回答 1

0

终于找到原因了:

如果<form>标签放在<table>标签之后,它就不起作用。在表格标记解决问题之前移动表格标记。如果有人有解释,只是为了理解这种行为:)

谢谢你 !

于 2013-03-26T06:08:55.910 回答