Hi everyone,
So I am implementing som Ajax on my site: http://www.xn--billig-bredbnd-wib.nu/
What I am trying to do is to a a small table when page loads, and when someone chooses "Hastighed" it will load the entire tabel in order to sort alle results.
I have used this tutorial to load the full mysql datatabel using Ajax Onclick: http://www.phpgang.com/fetch-data-from-xml-json-mysqli-using-jquery-ajax-php_733.html (under "Fetching Data from MySQL Database using Ajax" )
code:
function fetchfromMysqlDatabase() {
$.ajax({
type: "GET",
dataType: "html",
url: "getrecords.php",
cache: false,
beforeSend: function() {
$('#res3').html('loading please wait...');
},
success: function(htmldata) {
$('#res3').html(htmldata);
}
});
}
The HTML form:
<form class="form-inline" style="text-align:center" onClick="fetchfromMysqlDatabase();" >
The problem is that it loads evertime i click, which is making it impossible to use the filter function.
So my question is: How do i make this code only run once, when I click the form the first time?
Also - if i want to keep the "loading please wait..." for lets say 2 sec - what do I then need to do...
...Never worked with Ajax before so I am in deep waters!