发送使用jQuery值$ _GETjQuery、_GET

2023-09-10 15:49:27 作者:弄不死你i

我使用的是通过$ _GET等待两个值的PHP脚本。

我想通过使用jQuery的2价值观,这就是我不在太美好了。

这里的code我已经得到了。

有人能指出我朝着正确的方向?谢谢!

 函数xrate(ID,等级){

   $阿贾克斯({
      网址:ajax_xrate.php ID =+编号+&放大器;速度=+评级,
      全球:假的,
      键入:GET,
      数据类型:文本,
      异步:假的,
      成功:函数(){
         警报(好极了!');
      }
   });

}
 

(实际code从注释中复制)的

 函数xrate(ID,等级){
    VAR大馆=新的日期();
    $ .ajaxSetup({缓存:假});
    $ .ajaxSetup({
        scriptCharset:UTF-8,
        的contentType:应用程序/ x-WWW的形式urlen codeD;字符集= UTF-8
    });
    $阿贾克斯({
        网址:'?ajax_xrate.php时间戳='+ oDate.getMilliseconds()
        数据类型:HTML,
        数据:{itemid的:ID,keyrate:评级},
        缓存:假的,
        键入:GET,
        成功:函数(dataReturn){
            警报(dataReturn);
        }
    });
}
 

解决方案

 函数xrate(ID,等级){

   $阿贾克斯({
      网址:ajax_xrate.php
      数据: {
          ID:身份证,
          速度:评分
      },
      键入:GET,
      成功:函数(){
         警报(好极了!');
      }
   });

}
 
jquery mobile中php连接数据库的问题,求救

I'm using a PHP script that is waiting for two values through $_GET.

I'm trying to pass those 2 values using jQuery and that's where I'm not too good at.

Here's the code I've got.

Can somebody point me in the right direction ? Thanks !

function xrate(id,rating){  

   $.ajax({
      url: "ajax_xrate.php?id="+id+"&rate="+rating,
      global: false,
      type: "GET",
      dataType: "text",
      async:false,
      success: function(){
         alert('Bravo!');
      }
   });

}

(actual code copied from the comments)

function xrate(id,rating){ 
    var oDate = new Date(); 
    $.ajaxSetup({ cache: false }); 
    $.ajaxSetup({ 
        scriptCharset: "utf-8" ,
        contentType: "application/x-www-form-urlencoded; charset=UTF-8" 
    }); 
    $.ajax({
        url: 'ajax_xrate.php?timestamp='+oDate.getMilliseconds(), 
        dataType: 'html', 
        data: {itemid:id, keyrate:rating}, 
        cache: false, 
        type: "GET", 
        success : function(dataReturn){ 
            alert(dataReturn); 
        } 
    }); 
}

解决方案

function xrate(id,rating){  

   $.ajax({
      url: "ajax_xrate.php",
      data: {
          id: id,
          rate:rating
      },
      type: "GET",
      success: function(){
         alert('Bravo!');
      }
   });

}