2013-06-03 24 views
1

我有傳遞變量到我的AJAX的一個問題,即不工作「?testing.php ID = 1」,的Javascript傳遞變量在阿賈克斯

,這將無效:網址: '?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); 
     } 
    }); 
} 

這是一個語法問題嗎?我在這裏做錯了什麼?

+0

url:'testing.php?user_id ='+ theid – Givi

回答

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

一定要聲明這個id :) – JonathanRomer