pass multiple variable to bootstrap modal

点点圈 提交于 2019-12-04 21:06:06

You can pass multiple variables like this

var param1 = 2;
var param2 = 5;

var data = 'param1='+param1+'&param2='+param2;

$.ajax({
         type: "POST",
         url: "yourScript.php",
         data: data,
         success: function(html){

         }
       });

SEE THIS EXAMPLE if you want to get more data from <a> tag instead of getting only the id

easiest way to post multiple parameters would be to set the data element in the ajax call using an object literal

data: {
        'post_id':id,
        'myParam':"myvalue",
        'anotherOne':"again"
}

Then you would be able to access them as $_POST values in php

$post_id = $_POST["post_id"];
$myParam = $_POST["myParam"];
$anotherOne = $_POST["anotherOne"];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!