2012-01-10 127 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... 
}