I have a jQuery script to get some information from a external source (ajax) and while doing that a loader image should appear. JQuery does't seem to like it, because the line is not executed. During executing the the input should be disabled, but that code is skipped to.
My jQuery code:
$("#pnum").keyup(function(){
nieuw = $(this).val();
code = $('#pnum').val();
$("#pnum").css("background-color", "#FFC080");
if (oud != nieuw && option != 0 && code.length >= 1 && code.length <=4 ) {
$("#loaderImage").show();
$("input").prop('disabled', true);
$("#mode").prop('disabled', true);
$('#pnumTable').empty();
if (code.length >= 1) {
$.ajax({
url: "http://sistermans.diskstation.me/NetBeans/Postcodes/api-postcode.php",
dataType: "jsonp",
jsonpCallback: "postcodeResults",
data : {mode: option, pnum: code }
});
}
oud = nieuw;
$("#loaderImage").hide();
$("input").prop('disabled', false);
}
if (code.length < 1 || code.length > 4 ) {
$("#pnum").css("background-color", "yellow");
}
});
The part in html where the loader image and the answer should pop up:
<div id="loaderImage">
<p>Haal de gegevens op volgens methode : <br>
<div id="keuze"></div><p>
<p><img src="web_images/ajax-loader-hscrew.gif"></p>
</div>
<table>
<div id="pnumTable">
</div>
</table>
The answer will be shown in the pnumTable div. This allways works. The <div id="keuze">
is handled elsewhere.
I probably did something wrong, but I can't she where.
Is there somebody willing to help me out?