0

submit button (secondbutton) is not working if it comes from ajax page (Ajax.php) using jquery. In some browser it is working well. But, in some browser not working for example like some mobile browsers. plz help me to do.

      <!DOCTYPE html>       
            <html lang="ta">
            <head>
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
            <script>
           $(document).ready(function(){
                $("#MyRegister").on('submit', function(){
              if ($("#Button").val()=="FirstButton") {
                  $.ajax({
                    url: "Ajax.php",
                      method: "GET"
                   })
                .done(function(response) {
                    $("#Opj").html(response);
               });
                return false;
                 }
                return true;
             });
            </script> 
          </head>
            <body>
            <form id="MyRegister" method="post" action="Target.php">    
            <input id="MyName" type="text">
            <div id="Opj">  <input type="submit" id="Button" value="FirstButton"></div>
            </form>
            </body>
            </html>

Ajax.php

<input type="submit" id="Button" value="SecondButton">

2 Answers2

0

I think you have to bind the new button to the form like the answer in here

Community
  • 1
  • 1
  • no, that is different question. but here i have only single form. but the secondbutton is not working which is comes from Ajax.php – yaseen ahmed Jan 19 '17 at 22:00
0

Your JS has several syntax errors, try fixing them before trying again. If you're concise with the indentation you'll find syntax errors very easily.

Cleaned code:

$(document).ready(function(){
  $("#MyRegister").on('submit', function(){
    if ($("#Button").val()=="FirstButton") {
      $.ajax({
        url: "Ajax.php",
        method: "GET"
      })
      .done(function(response) {
        $("#Opj").html(response);
      });
      return false;
    }
    return true;
});
Phaze Phusion
  • 992
  • 6
  • 19