sGermosen
sGermosen

Reputation: 374

Call an url with parameters from jquery in mvc

I want to open a new url, pasing parameters using jquery, this is the way that im doing it,

  $('#BtnPrintFlujo').click(function(e) {

       var url = '@Url.Action("BillingxCashier", "Reports",new {area="Configurations" })';
       url += "/opParam=" + $("#Users option:selected").val() +
                    "&fromDate=" + $('#FromDate').val() +
                    "&toDate=" + $('#ToDate').val();

       var win = window.open(url);

       if (win) {
          win.focus();
       } else {
                    alert("Porfavor, debes permitir que se abran las ventanas emergentes o el reporte no va a salir :'( ");
               }
            });

but, it said this error

 Request.Path dangerous on the client (&).

Upvotes: 2

Views: 273

Answers (1)

Yash Soni
Yash Soni

Reputation: 764

 $('#BtnPrintFlujo').click(function(e) {

       var url = '@Url.Action("BillingxCashier", "Reports",new {area="Configurations" })';
       url += "?opParam=" + $("#Users option:selected").val() +
                    "&fromDate=" + $('#FromDate').val() +
                    "&toDate=" + $('#ToDate').val();

       var win = window.open(url);

       if (win) {
          win.focus();
       } else {
                    alert("Porfavor, debes permitir que se abran las ventanas emergentes o el reporte no va a salir :'( ");
               }
            });

you missed an question mark before first parameter,

url += "?opParam=" + $("#Users option:selected").val() +

try this

Upvotes: 2

Related Questions