I'm having a hard time on this one, and I cannot find any relevant questions (although I think I have used quite a lot of relevant searchterms (ref: the title)... So here goes:
<td class="noprint">
<a class="ui-button isbillable" onclick="switchBillable($(this))" value="1">Aanrekenbaar?</a>
<a class="ui-button isbillable" onclick="switchBillable($(this))" value="2">Aanrekenbaar?</a>
<a class="ui-button isbillable" onclick="switchBillable($(this))" value="...">Aanrekenbaar?</a>
</td>
I want to execute an AJAX-request (PHP) upon pageload giving the ui-buttons a specific color depending if the AJAX-request returns TRUE or FALSE. This code however is never executed (tested with an 'alert()'):
$(document).ready(function(){
$( ".isbillable" ).load( function() {
var prestId = $(this).val();
$.ajax({
url: "ajax/check_billable.php",
data: { q: prestId },
success: function () {
if (response == true) {
$(this).removeClass('isbillable');
$(this).addClass('billable');
}else{
$(this).removeClass('isbillable');
$(this).addClass('notbillable');
}
}
});
}).button({
icons: { primary: "ui-icon-help" },
text: false
});
$( ".billable" ).button({
icons: { primary: "ui-icon-notice" },
text: false
});
$( ".notbillable" ).button({
icons: { primary: "ui-icon-check" },
text: false
});
});
Using Firebug I cannot detect any AJAX calls, so this code is never executed - I have tried with load(), on('load',,), bind()