This works fine, but consists hardcode in "url" section:
<script type="text/javascript">
function aj() {
var a = $('#price').val();
$.ajax({
url: "/Item/GetStatus?price=" + a,
type: this.method,
success: function (result) {
$('#w').html(result);
}
});
return false;
}
</script>
This doesn't consist hadrcode, but it is not clear how to pass variable "a".
<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>
Using variable is not necessary. How can I pass variable? Maybe I use incorrect helper, or overload?