传递多个参数用$阿贾克斯网址 [英] Passing multiple parameters with $.ajax url

查看:132
本文介绍了传递多个参数用$阿贾克斯网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我顺便parrameters阿贾克斯url.I面临的问题,认为错误是parametters code syntax.Plz帮助。

  VAR时间戳= NULL;
功能waitformsg(ID,姓名){

    $阿贾克斯({
        键入:邮报,
        网址:getdata.php时间戳=+时间戳+的uid =+编号+的uname =+的名字,
       异步:真正的,
       缓存:假的,
       成功:功能(数据){


        });
     }
 

我在访问这些参数如下:

 < PHP

  $ UID = $ _ GET ['UID'];


 ?>
 

解决方案

为什么要结合GET和POST?使用的一个或另一个。

  $。阿贾克斯({
    类型:'后',
    数据: {
        时间戳:时间戳,
        UID:UID
        ...
    }
});
 

PHP的:

  $的uid = $ _ POST ['UID'];
 

或者,只是格式化你的要求正确(你错过了与号为GET参数)。

  URL:getdata.php时间戳=+时间戳+&放大器; UID =+编号+&放大器;的uname =+的名字,
 

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'];


 ?>

解决方案

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,

这篇关于传递多个参数用$阿贾克斯网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆