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

253
Views
How To submit form with ajax that was already loaded with ajax, without reload the current page?

I'm struggling with this problem for about week, What I need to do, Is submit form with ajax, That was already loaded with ajax, I have tried many solutions but nothing work, So if someone know, the right approach, I will be appreciated, And Thank advanced.

This is my code :

<form class="w3-container" method="POST" action="forms-submitting" id="SignIN">
        <p>
        <label><b> إسم المستخذم </b></label>
        <input class="w3-input w3-border" type="text" name="user_name">
        </p>
        <p>
        <label><b> كلمة المرور <b></label>
        <input class="w3-input w3-border" type="password" name="pass_word">
        </p>
        <p>
            <button type="submit" class="w3-button w3-text-blue"> تسجيل الدخول </button>
        </p>
</form>

And this is my ajax code:

$("#SignIN").submit(function(e) {
  var url = "forms-handle.php";
  $.ajax({
       type: "POST",
       url: url,
       data: $("#SignIN").serialize(),
       success: function(data)
       {
           alert(data); 
       }
  });
  e.preventDefault();
});
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since you're not using the regular submit you could change your button to button type and attach click event to this button like :

<button type="button" id="login" class="w3-button w3-text-blue"> تسجيل الدخول </button>

$('body').on('click', '#login', function(e) {
  e.preventDefault();

  $.ajax({
       type: "POST",
       url: "forms-handle.php",
       data: $("#SignIN").serialize(),
       success: function(data)
       {
           alert(data); 
       }
  });
});

NOTE : Since the form is loaded dynamically you should use event delegation .on().

Hope this helps.

over 4 years ago · Santiago Trujillo 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!