I am using $.post() to input some data into a server. Within the ajax file I want to add a 1 to a variable containing a number. However, when the data is put into the server, instead of adding a 1 it instead puts 1. I feel stumped by this. What am I doing wrong. I swear for a second I got it to work, then next thing I know it stops working. Here is the code.
$liker = $_POST['likes'];
$likes = $liker + 1;
send_data_to_server($likes);
Update
I have figured out that the likes is not being sent through the ajax post. I will try to troubleshoot a solution since I see the jquery code is not acting right. Here is the code below if anyone wants to give it a shot while I troubleshoot it on my own.
$('#submitter').click(function() {
var search_term = $('#band_request').val();
$.post('ajax_searchlike.php', {
search_term: search_term
}, function(data) {
/*this section is where I know the problem is
$('#like_temp_holder').append(data);
});
var likes = $('#like_temp_holder').val();
*/
$.post('ajax_send_band_request.php', {
likes: likes
}, function(data) {
$(data).appendTo("#response_from_request_verification");
});
});
< /script>
<div id="like_temp_holder"></div>
<div id = "response_from_request_verification"></div>
This was my fault. The first .post() is pointless. I attached the first ajax file to the second and got the job done. I like to go AJAX overboard. Lesson learned: why make multiple AJAX calls when you can simply do one.