Passing multiple parameters with $.ajax url

后端 未结 2 1208
终归单人心
终归单人心 2020-12-14 19:52

I am facing problem in passing parrameters with ajax url.I think error is in parametters code syntax.Plz help.

    var timestamp = null;
function waitformsg         


        
相关标签:
2条回答
  • 2020-12-14 20:21

    Why are you combining GET and POST? Use one or the other.

    $.ajax({
        type: 'post',
        data: {
            timestamp: timestamp,
            uid: uid
            ...
        }
    });
    

    php:

    $uid =$_POST['uid'];
    

    Or, just format your request properly (you're missing the ampersands for the get parameters).

    url:"getdata.php?timestamp="+timestamp+"&uid="+id+"&uname="+name,
    
    0 讨论(0)
  • 2020-12-14 20:30

    why not just pass an data an object with your key/value pairs then you don't have to worry about encoding

    $.ajax({
        type: "Post",
        url: "getdata.php",
        data:{
           timestamp: timestamp,
           uid: id,
           uname: name
        },
        async: true,
        cache: false,
        success: function(data) {
    
    
        };
    }​);​
    
    0 讨论(0)
提交回复
热议问题