I’m using jquery’s $.get() to find out how many entries are in a table. I want the returned value to be an Int but it seems to be something else. How do I work with this? this is the code I have. I’m sure I’m just going about this wrong. My background is many java.
var num = checksize();
function checksize(){
$.get("../php/checktablezie.php", function(data){
return data;
});
}
You cannot do it like that. $.get is an asynchronous request, so your checksize() function will return instantly. Your anonymous function will be executed when the Ajax call is done, but that will be after checksize() has been returned.
Instead, you’ll have to put whatever should be done with
numinside your anonymous function, like this: