2011-05-30 33 views
-1

這工作得很好,但在「URL」部分包括硬編碼變量。插入jQuery的JS在Url.Route

<script type="text/javascript"> 
    function aj() { 
     var a = $('#price').val(); 
     $.ajax({ 
      url: "@Url.RouteUrl(new {controller = "Item", 
            action = "Getstatus", 
            price = "a"})", 
      type: this.method, 
      success: function (result) { 
       $('#w').html(result); 
      } 
     }); 
     return false; 
    } 
</script> 

使用變量不是必需的。我怎樣才能傳遞變量?也許我使用不正確的幫手,或超負荷?

回答

2

你可以ofcourse只是做

url: "@Url.RouteUrl(new {controller = "Item", action = "Getstatus"})?price=" + a, 
+0

只需添加請 「}」,你錯過了。 – 2011-05-30 19:25:02