I am trying to create a form that posts data via JQuey and populates the return into the same DIV. This way the page does not refresh on post action.
<div id="add_value_form">
<form method="POST" action="#" onsubmit='return false'>
<!-- input fields -->
<input type="submit" value="Add" onclick='post_form("/add_value");'>
</form>
</div>
The JS function:
function post_form(url) {
$.post(url, {'test':'test'}, function(data) {
$("#add_value_form").empty().append(data);
}, "text");
}
This works perfectly in FF3, however it would only work randomly in IE6/7.
The server confirms that post requests are coming through from IE, yet it would get the post data only occasionally.
Curious, I decided to alert the data variable:
$.post(url, {'test':'test'}, function(data) {alert(data);}, "text");
Surely enough, FF3 would print out the return HTML every time, while IE6/7 would mostly print blanks, with an occasional HTML return. I was not able to find anything on this problem, so what am I doing wrong?
Resolved: I tracked this to an HTTP redirect I had in my request handling code. So the function handling the POST request would throw a redirect, and IE does not like it. I had a total mental constipation at the time, and I don't really need the redirect.
The weird part, of course, is that this works in FF, and IE would on occasion work as well, with the redirect in place.