var pageNumber = 1;
$.ajax({
type: 'post',
url: 'ajax_results.php',
data: {
//format "variableNameToSend: valueToSet"
query:'funny cats',
page:pageNumber
},
error: function() {
console.log("An error has occurred :(");
},
success: function (response) {
//do somthing with response eg:
$('#output').html(response);
}
});
if(isset($_POST['query']) && isset($_POST['page'])){
// EXAMPLE { results = Query database for results with $_POST['query'] and page offset of $_POST['page']; }
foreach($results as $result){
echo $result . "\n";
}
}
dataType: 'jsonp'