I want to set up a while loop within a ajax .post jquery function. Is it even possible? If not, is there an alternate solution to the problem. The user input data is dynamic and the quantity changes for each user. That is a must. Here is the code below.
$('#send').click(function() {
var rad = 'radius_' + k + ' : ' + 'radius_' + k + ', ';
var add = 'address_' + k + ' : ' + 'address_' + k + ', ';
var latit = 'latitude_' + k + ' : ' + 'latitude_' + k + ', ';
var longit = 'longitude_' + k + ' : ' + 'longitude_' + k + ', ';
$.post('ajax_set_place.php', {
while (k < f) {
print(rad);
print(add);
print(latit);
print(longit);
var k = k++;
},
user_id: user_id,
number_of_places: number_of_places
},
function(){
$('#message_sent').html('Message Sent!');
}
});
I don’t think that would be possible, as the data parameter is an object.
What are you trying to achieve exactly?
If you are trying to keep posting user’s data to a file, I’d use
…and use a while loop outside to update the parameters dynamically.
If not. I’m not sure what your trying to achieve as far as an alternative goes.
I hope this answer was helpful in some way.
Oh and another thing you can customise what the data would be by doing something like this