2012-01-10 108 views
-2

在下面的腳本中,stateId的值未傳遞給控制器​​。誰能幫我這個?stateid的值未傳遞給控制器​​

$("#ddlState").bind("change",function() { 
    var stateId = $(this).val(); 
    $("#div_city_wrapper").load("page/new_city", {"stateId": stateId}, function(r) { 
     alert('done loading'); 
    }); 
}); 
+1

顯示控制器?你的例子超級模糊。 – tpae 2012-01-10 09:32:23

+1

您確實需要在此處添加更多信息,否則問題可能會被關閉。 – 2012-01-10 14:22:29

回答

0

旁邊添加額外的alert與評論到你的JavaScript:

$("#ddlState").bind("change",function() 
{ 
    var stateId = $(this).val(); 

    alert(stateId); // if this isn't null or undefined, then the problem is in your controller 

    $("#div_city_wrapper").load("page/new_city", {"stateId": stateId}, function(r) { 
     alert('done loading'); 
    }); 
}); 

如果問題是在您的控制器,那麼你需要將其添加爲一個參數,例如

function new_city($stateId = NULL) 
{ 
    if ($stateId === NULL) 
    { 
     // nothing was passed to the controller, so redirect somewhere or display an error 
    } 

    // the rest of your function... 
}