I'm sure jQuery works fine, but for some reason it isn't for me. I can't even put it into a jsFiddle because it doesn't like Ajax, but my statements involving $(this).children
are not working at all. I'm not getting any errors... what am I doing wrong?
JS
$('.submitNewOrder').submit( function() {
$(this).children('input[type=\"submit\"]').prop('disabled',true); // Doesn't work
$(this).children('.saving').fadeIn('fast'); // Doesn't work
$.ajax({
url: 'scripts/submitNewOrder.php?catID=1',
data: newOrder,
type: 'POST',
mode: 'abort',
success: function(){
$(this).children('.saving').fadeOut('fast', function() { // Doesn't work
$(this).children('.success').fadeIn('fast'); // Doesn't work
});
},
error: function(){
$(this).children('.error').fadeIn('fast'); // Doesn't work
}
});
return false;
});
HTML
<form class="submitNewOrder">
<p>
<input type="submit" value="Save order" />
<span class="saving" style="display:none">Saving changes...</span>
<span class="success" style="display:none">Saved!</span>
<span class="error" style="display:none">There was a problem saving :(</span>
</p>
</form>