Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
566 views
in Technique[技术] by (71.8m points)

jquery - Passing multiple parameters with $.ajax url

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(id,name) {

    $.ajax({
        type:"Post",
        url:"getdata.php?timestamp="+timestamp+"uid="+id+"uname="+name,
       async:true,
       cache:false,
       success:function(data) {


        });
     }

I am accessing these parameters as follows

<?php          

  $uid =$_GET['uid'];


 ?>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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,

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...