Reputation: 725
I will try to explain it a bit better.
I have REST api I'm connecting to via the URL in the ajax. When I get that information I want to update the content within so the content is updated according to the data got from the api call.
<button onclick="myFunction()">LOAD</button><br /><br />
<div class="spinner bar hide">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div class="searchtable"><?php include 'hotels/hotelList.php';?></div>
<script>
function myFunction() {
$('.searchtable').addClass('hide');
$('.spinner').removeClass('hide');
$.ajax({
url: 'hotels/hotelSortBy.php?name=<?php echo $name;?>&arrival=<?php echo $arrival;?>&departure=<?php echo $departure;?>&guests=<?php echo $numberOfGuests;?>'
}).done(function() {
$('.spinner').addClass('hide');
$('.searchtable').removeClass('hide');
});
}
</script>
Upvotes: 0
Views: 14495
Reputation: 1058
The issue is with your ajax call functionality
you have to change your ajax call like below
$.ajax({
type: 'GET',
data: {'name':'<?php echo $name;?>','arrival':'<?php echo $arrival;?>','departure':'<?php echo $departure;?>','guests':'<?php echo $numberOfGuests;?>'},
url: 'hotels/hotelSortBy.php',
success: function (data) {
// do what ever you want to do with this response data
},
error: function (xhr) {
// do what ever you want to do when error happens
}
});
Thats the way to send GET request to a url using ajax
Upvotes: 1