如何以其他形式发送变量这段代码是否正确?

时间:2013-09-29 00:19:13

标签: javascript php ajax jquery

$("#delete").click(function() {
    deleterecord();
});

function deleterecord(){
    var id = $("#iduser").val();
    alert("aw"+id);
    var id     = $('#iduser').attr();   
    e.preventDefault();
    pressed = "delete"  

    $.ajax({
        type: "post",
        url: "IngSave.php",
        data: "&idshit="+ id,
        data: "&gagawin="+ pressed,
        success: function(){
            alert("ATTENTION");
            $("#usertbl").html(data);
        }
    });
    return false;
}

我没有在$_POST['idshit'];文件中获取变量$_POST['gagawin'];IngSave.php

2 个答案:

答案 0 :(得分:2)

试试这个:

$.ajax({
    type: "post",
    url: "IngSave.php",
    data: {idshit:id,gagawin:pressed},
    success: function(){
        alert("bitch");
        $("#usertbl").html(data);
    }
});

答案 1 :(得分:2)

您的data来电中有两个ajax参数错误,请将其更改为

$.ajax({
    type: "post",
    url: "IngSave.php",
    data: "idshit="+id+"&gagawin="+pressed, // or - { idshit:id,gagawin:pressed }
    success: function(){
        alert("bitch");
        $("#usertbl").html(data);
    }
});