I want to pass multiple values through ajax request like
var ids = 10 ,15,30;
is it possible to do this if not how do i pass the ids in the request?
$.ajax({
type: "POST",
url: $('#baseurl').val()+"/ajax_requests/testing.php",
data:{row :ids,action:"get_values"},
async :false,
cache: false,
success: function(result){
if(result)
{
alert("success")
}
}
});
Once i pass these values how do i go about in fetching the results in test.php
Actually, there are a lot of possibilities how to send several values. The solution depends only on how you would like to parse them in PHP. Here are some possibilities that gets on my mind:
Just make a string with comma-separated values. Like:
var ids = "10,15,30"; After that in PHP you will have to split these values by ",".
Note: there's very good function in jQuery that allows to pack easily all needed information from the page: .serialize()
You can pass this data as string
data:{row :"10,15,30",action:"get_values"},
or as array
data:{row[]:10, row[]:15, row[]:30,action:"get_values"},
depending what your php expect
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.