0

I have the following code which works fine but shows the appended query string:

 var url = '@Url.Action("RawDataPageTable", "Chlor", new { id = Model.Senid })';
 url = url +  '?Voting=' + isChecked;

 window.location = url;

With how I am sending the parameter info, it is shown on the browser.

I tried to do the following so no query string is not visible in place of window.location = url but it did nothing:

 $.redirect(url,
 {
     Voting: isChecked
 });

Is there any other way to pass data in such a way that it is not visible in the URL? Note that I am using jQuery.

Anyway to do this in a $.post in jquery so we can pass the data?

Nate Pet
  • 44,246
  • 124
  • 269
  • 414
  • `$.post` will make an ajax request: https://api.jquery.com/jquery.post/ – Artur Oct 14 '20 at 15:17
  • Does this answer your question? [pass post data with window.location.href](https://stackoverflow.com/questions/2367979/pass-post-data-with-window-location-href) – Artur Oct 14 '20 at 15:18
  • You could also encode your querystring. Sending the unencoded data to the server, which will redirect you to an url with the encoded string. – Artur Oct 14 '20 at 15:18

2 Answers2

0

I would add a form to your page, with method="post", put all your variables as hidden inputs, then submit the form.

mykaf
  • 1,034
  • 1
  • 9
  • 12
0

The answer is yes. And the way to do it is to use a FORM. In particular, you should learn about the FORM method (learn about [REST][1] commands).

It sounds like you should be using POST.

[1]: https://www.restapitutorial.com/lessons/httpmethods.html#:~:text=The%20primary%20or%20most%2Dcommonly,or%20CRUD)%20operations%2C%20respectively.

ControlAltDel
  • 33,923
  • 10
  • 53
  • 80