views:

41

answers:

1

Hi, I'm working on a simple, one field, form that works with AJAX. Every time I submit the form and then refresh the page, I get a 412 error (Precondition failed: The precondition on the request for the URL /user.html evaluated to false.). Eventually this form will be AJAX, but right now, I'm just using jQuery to receive the click event on the submit button and then give me an alert. This is pretty simple and I've done things with forms just like this many times before. Any ideas on what's going on here?

I'm running the site locally on MAMP on Snow Leopard.

And to clarify, I don't get the error when I don't submit the form and refresh, so it definitely has something to do with either the html or the jQuery. (but I don't see how either of those could produce this error).

EDIT: The html code:

<form id="add-form" method="post" action="">
        <input type="text" name="add-input" value="http://example.com" />
        <input type="submit" name="add-submit" value="Add" />
</form>

THe jQuery:

$(document).ready(function() {

$('input[type="submit"]').click(function() {

    link = $('input[name="add-input"]').val();
    alert(link);

   return false;
});

});
+1  A: 

Looks more like a server issue to me.

Is mod_security enabled on your server?

Some hosting companies use mod_security or other similar filters to block web form submissions containing certain key words or suspicious symbols, in order to prevent comment spam or hack attempts. Occasionally these security rules can block legitimate requests. 1

As you reload the page, this might be detected as comment spam by mod_security and cause this HTTP response.

JochenJung
EDIT: Ok I figured it out, and that solved the problem! Thanks!
WillyG