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

178
Views
How do I stop javascript from posting twice when clicking off date field?

When a user clicks on a date field and enters a date, a post request is sent. But then when the user clicks somewhere off the field, the request sends a second time. How do I correct this? I tried focusout() but the problem persists.

$(".cInput").focusout(function(){
    var fieldName = this.name;
    var fieldValue = this.value;
    var cid = $('meta[name="cid"]').attr('content');
    var cnum = $('meta[name="cnum"]').attr('content');

    $.ajax({
        /* the route pointing to the post function */
        url: '/cUpdate',
        type: 'POST',
        /* send the csrf-token and the input to the controller */
        data: {_token: CSRF_TOKEN, moduleID: $("#moduleID").text(), checkName: fieldName, checkValue: fieldValue, cid: cid, cnum: cnum},
        dataType: 'JSON',
        /* remind that 'data' is the response of the AjaxController */
        success: function (data) { 
            window.history.replaceState({}, document.title, thisURL);
        }
    });
});
about 4 years ago · Santiago Trujillo
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!