javascript - 在javascript中传递两个不同的变量?

标签 javascript php jquery ajax

这是我的第一页的 javascript

 <script>
        function MessageDetailsById(id)
        {
            $("#active"+id).css({"color":"red"});
            var http = new XMLHttpRequest();
             var url = "Ajax.php";
             var adm = "<?php echo $admno; ?>";
            var params = "Id="+id;"adm="+adm;
            http.open("POST", url, true);
            http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            http.onreadystatechange = function() {
            if(http.readyState == 4 && http.status == 200) {
            //alert(http.responseText);
                        }
        }

            http.send(params);

            window.location.href="#";


        }

        </script>

这是ajax.php的编码

<?php
include("model.php");
$DB=new database;

if(isset($_POST["Id"]))
{
    $DB->updateMassageTitleStauts($_POST["Id"],$_POST["adm"]);

}
else
{
    header("Location:index.php?ajaxmas=wHgfghks^^%&fnjfskjdfb");
}
?>

我想发送一个 php 变量,另一个是 div 的 id...如何发送两个参数并在另一端接收它们???请详细更正此代码我不是专家???

最佳答案

对于后数据编码:

var params = "Id=" + id + "&adm=" + adm;

使用&作为分隔符。

关于javascript - 在javascript中传递两个不同的变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42639371/

相关文章:

javascript - 从哪里导入js文件比较好?

jquery - 简单滚动内容 ID 不显示 iframe 内容

javascript - Ajax获取内容后,我想调用另一个ajax函数

javascript - 匹配不连续的重复字符

PHP-DI:注入(inject)构造函数的接口(interface)无法正确解析

php - 如何知道该行属于哪个表?

javascript - 重新加载页面后显示警报

javascript - Meteor Accounts.loginWithPassword "400 Match Failed"错误

php - 在 codeigniter 中使用 mpdf 为 foreach() 提供的参数无效

jquery 单击仅触发一次