【问题标题】:ajax send request to php same valueajax向php发送请求相同的值
【发布时间】:2013-01-19 20:50:55
【问题描述】:

我在将一个变量 (i) 发送到我的 php.ini 时遇到问题。 我的变量 i 每次都是 6,我该如何解决?

$(document).ready(function(){
for (i=1; i<=5; i++){
    $('#rate'+ i +'_').click(function(){
    sendValue($(this).val(),i);
    });
}
});
function sendValue(str,str2){
$.post("/php/test.php",{ sendValue: str, sendValue2 : str2 },
    function(data){
    $('#display').html(data.returnValue);
    }, "json");
}  

【问题讨论】:

    标签: php ajax request send


    【解决方案1】:

    i 作为数据传递给click 事件的处理程序

    for (i=1; i<=5; i++){
        $('#rate'+ i +'_').click(i, function(e){
        sendValue($(this).val(),e.data);
        });
    }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多