Really weird, the following codes seems to work sometimes It always worked (on my Macbook Pro) and other computers, but when I tested today at my university (IE) it only showed the message ‘Success’ without handling the action in process-mailing.php (which works btw)
$("form#mailing").submit(function(event){
event.preventDefault();
$.post('process-mailing.php',$("#mailing").serialize(),function(data){
$("<div class='form-message-succeed'>Succesvol toegevoegd!</div>").hide().appendTo("#mailing").fadeIn("slow");
$("#mail").add("#go-mailing").attr("disabled", "disabled");
});
});
<form id="mailing" method="post" action="process.php">
<fieldset>
<legend>E-mail</legend>
<label for="mail" id="mail-label">Je mail adres</label>
<input type="text" id="mail" name="mail" placeholder="voorbeeld@domein.com">
<label for="go-mailing" id="gol">Voeg toe</label>
<input type="submit" class="go" id="go-mailing" value="Voeg Toe">
</fieldset>
</form>
Can it be that this works in certain browsers only? And how can I make it work everywhere?
In IE the event object is not passed as the first argument to an event handler. Instead it is a global variable
solution and quoted from:
Javascript: IE event.preventDefault is null or not an object