ahmed salah

ahmed salah

  • 1.2k
  • 547
  • 64.3k

why when ajax jquery call applied it call OnGet and not call OnGetshif

Jun 23 2023 7:39 PM

I work on razor asp.net . i face strange issue when apply ajax request it catch OnGet function get method 

but correct or what I expect is to hit or catch OnGetshiftDataUp

why it catch on get and not catch OnGetshiftDataUp 

when apply jquery ajax request it not catch  OnGetshiftDataUp and catch OnGet why that happen 

i write on url url: 'ShelfLabelPrinterSetUp?handler=shiftDataUp' so why it go to OnGet

full code sample

   $('#save-btn').click(function () {
                
                var param1Value = $('#editshelflabelModal #edit-ip').val();
          
                console.log(param1Value);
                $.ajax({
                    url: 'ShelfLabelPrinterSetUp?handler=shiftDataUp',
                    type: "GET",
                    dataType: "json",
                   
                    data: { serverip: param1Value },
                    success: function (result) {
                        alert(result);
                    },
                    error: function (xhr, status, error) {
                        console.log(error);
                    }
                });
            });
public ActionResult OnGetshiftDataUp(string serverip)
        {

           return new JsonResult("Success");

        }
public void OnGet()
        {
        }

<div class="modal fade" id="editshelflabelModal" tabindex="-1" role="dialog" aria-labelledby="userDetailsModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <h5 class="modal-title" style="text-align:center;">
               

            </h5>
            <div class="modal-header">
                <h5 class="modal-title" id="editshelflabelModaldata" style="margin-left:200px;">Hi,@TempData["UserID"]</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="edit-form">
            <div class="modal-body">
        
                
                    <div class="form-group">
                        <label for="edit-server">Server IP</label>
                        <input type="text" class="form-control" id="edit-ip" name="serverip">
                    </div>
                    <div class="form-group">
                        <label for="edit-printer">Printer Name</label>
                        <input type="text" class="form-control" id="edit-printername" name="printername">
                    </div>
                    <div class="form-group">
                        <label for="edit-locationsdata">Location Name</label>
                        <input type="text" class="form-control" id="edit-Location"  name="Location">
                    </div>
                    
              
    

            </div>
               
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" id="save-btn">Save changes</button>
                
            </div>
            </form>
        </div>
        
    </div>
    
</div>

 


Answers (1)