簡體   English   中英

Javascript傳遞變量在Ajax中不起作用

[英]Javascript Passing variable not working in Ajax

我有一個問題將變量傳遞給我的ajax,其中:

這將有效:url:'testing.php?id = 1',

這不起作用:url:'testing.php?id = theid',

以下是完整的代碼:

function myfunc(theid) {
    $.ajax({
        url: 'testing.php?user_id=1',
        success: function() {
            alert('this worked' + venueid);
        }
    });
}

並且此代碼不傳遞變量值:

function myfunc(theid) {
    $.ajax({
        url: 'testing.php?user_id=theid',
        success: function() {
            alert('this worked' + venueid);
        }
    });
}

這是語法問題嗎? 我在這里做錯了什么?

function myfunc(theid) {
$.ajax({
   url: 'testing.php?user_id='+ theid,
   success: function(){
   alert('this worked' + venueid);
                    }
});
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM