AJAX:GET方法中的隐藏字段

时间:2014-05-16 17:19:10

标签: php jquery ajax codeigniter

当我登录有id =" voteinc"我调用了这个函数,我在Chrom中收到了这条消息:

http://localhost/PSI/Dokumentacija/Faza5/Implementacija/votes/voteAlg?incdec=inc&alg=9&a=addcomment&_=1400260139619

我不知道第四个参数出现在哪里,GET方法发送了3个参数。

$(document).ready(function(){
  $("#voteinc").click(function(){
    $.ajax({
        type:'GET',
        async: false, 
        url: $("#ratesection").attr('action'),
        data: {
            incdec: $("#voteinc").attr('value'),
            alg: $("#algcode").attr('value'),
            a: $("#addcomment").attr('id')
        },
        dataType: 'text', 
        cache: false,
        success: function(mess) {
            console.log(mess);
            if(mess=='voted') {
                alert("Glasali ste vec!");
            } else if (mess=='error') {
                alert("Problem sa bazom");
            } else {
                $("#algRate").val(mess);
            } 
        }
    });

    return false;
  });
});

1 个答案:

答案 0 :(得分:2)

添加的参数是jQuery的'cache-buster',用于绕过发起者(你)和源URL之间的缓存。由于您已将缓存设置为false,因此jQuery会为您附加缓存破坏程序

See jQuery AJAX documentation here