How to pass in .load function of jquery, the parameter include in url.
url recived in create.cshtml => http://…/Invoiced/Create/1
InvoicedDetail is a partialView , this contain list of details by id, this id is the parameter in ulr http://…/Invoiced/Create/1, how to cathc this parameter “1” to send in .load function ?
thanks.
Create.cshtml
<p>Details list</p>
<div id="InvoicedDetails_content"><div>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
// parameter = ?;
$('#InvoicedDetails_content').load('/InvoicedDetail/Index/' + parameter);
});
</script>
Never hardcode urls or any string concatenations. Always use urls helpers when you need to generate a url in an ASP.NET MVC application:
In this example I am using the
idparameter which assumes that you have this route parameter defined in your route definitions. Adapt the name if necessary.