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>
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>
Share
Improve this question
edited Feb 19, 2015 at 16:20
Troels Johannesen
asked Feb 19, 2015 at 15:19
Troels JohannesenTroels Johannesen
7252 gold badges8 silver badges31 bronze badges
5
-
Your question is not clear. Are you saying that you would like the data returned from the AJAX request appended to the
searchtable
elements? – Rory McCrossan Commented Feb 19, 2015 at 15:21 - is this part of generated HTML document? or source of php.file? – Alex Commented Feb 19, 2015 at 15:22
- Are you absolutely sure that your file isn't called? You might want to set up your URL in an extra variable and check if before starting the AJAX call. – Tacticus Commented Feb 19, 2015 at 15:26
- 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 <div class="searchtable"> so the content is updated according to the data got from the api call. – Troels Johannesen Commented Feb 19, 2015 at 16:20
-
you still didn't answer to my question: what is that? is it part of html code? if yest - it is wrong (includes
<?php
) is it php file? if yes - why do you show it to us? show us the html generated by script please – Alex Commented Feb 19, 2015 at 17:30
1 Answer
Reset to default 1The 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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745359894a4624309.html
评论列表(0条)