Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Button Click to return to the same page with same input parameters

I want users to navigate back to the same page after the button is clicked on the page. If the user URL is https://localhost:xxx/Inventories/Index/38?custID=38&rmName=A2A click on the button should do the processing and come back to the same page with same input parameter. On the button click I have the below logic

<script type="text/javascript">
    $(document).ready(function () {
        $(document).on("click", "#buyNow", (function (e) {
            e.preventDefault();
            e.stopImmediatePropagation();
                var id=$(this).data("id");
            onBuyNow(id);
        }));

        function onBuyNow(id) {
           
            var quantityReq = $("#quantityReq" + id).val();
            var customerId = $("#customer" + id).val();
            var data = {
                customerID: customerId,
                quantityReq: quantityReq,
                invetoryID: id
            };

            $.ajax({
                type: 'POST',
                url: '@Url.Action("OrderItem", "Inventories")',
                data: data,
                dataType: "json",
                success: function (result) {
                    alert("hello");
                    var url = '@Url.Action("Index", "Inventories")';
                    var rmName = @HttpContextAccessor.HttpContext.Request.Query["rmName"];
                    alert(roomId);
                    window.location.href = `${url}?custID=${customerId}&rmName=${rmName}&success=true`;
                },
                error: function (error) {
                    alert(error);
                }
            });
            };
        });
</script>

When I click on the button after the button does the processing I can see the alert with hello but when it tries to get the query parameter from the current page @HttpContextAccessor.HttpContext.Request.Query["rmName"]; it keeps throwing

enter image description here

Is there suggestion how I can go back to the existing page after the button click is successful. Any help is greatly appreciated

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Like where should I add the quotes?

As @GuyVdN said, you should modify the rmName to a string instead of being the object.

You should put it like this and then it will work.

                var rmName = '@HttpContextAccessor.HttpContext.Request.Query["rmName"]';
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!