2017-07-01 1 views
0

jqlib.js ist https://code.jquery.com/jquery-3.2.1.jswas ist der Fehler in Ajax-Code ist

nothing is happing i m trying to add to number using ajax using jquery 3.2.1.js

kann nicht den Fehler in diesem Code finden kann mir jemand sagen, wo in diesem Code ist der Fehler

add.php

<html> 
<body> 
<script type="text/javascript" src="jqlib.js"></script> 
    <form id="tt"> 
     <table> 
      <tr> 
       <td>Enter first Number</td> 
       <td><input type=text name=t1 ></td> 
      </tr> 
      <tr> 
       <td>Enter 2nd Number</td> 
       <td><input type=text name=t2></td> 
      </tr> 
      <tr> 
       <td><input type=button value="OK" onClick="cal()"></td> 
      </tr> 
      <tr> 
      <td>Addition</td> 
      <td><input type=text name=t3 id="tt1"></td> 
      </tr> 
     </table> 
    </form> 
</body> 
</html> 
<script type="text/javascript"> 
    function cal() 
    { 
     var frm = $("#tt"); 

     $.ajax(
     { 
      type:"POST", 
      url:"ajax.php", 
      data:frm.serialize(), 
      sucess:function (data) 
      { 
       $("#tt1").val(data); 
      } 
     }); 

    } 
</script> 

ajax.php

<?php 
if(!empty($_POST)) 
{ 
if(($_POST['t1']!="")|| ($_POST['t2']!="")) 
{ 
    $z = $_POST['t1'] + $_POST['t2']; 

} 
else 
{ 
    $z ="please enter data"; 
} 
echo $z; 
} 
else 
{ 
echo "please enter data"; 
} 
?> 
+0

leer nichts –

+0

überprüfen @SepehrRaftari ‚s Antwort zeigt sein sollte –

+0

@AyushmanKasyap überprüfen SepehrRaftari die Antwort, und wenn es hilft, upvote und akzeptieren Sie es. – YvesLeBorg

Antwort

0

Ihr Skript ändern wie folgt und überprüfen, ob eine Warnung oder nicht

<script type="text/javascript"> 
function cal() 
{ 
    var frm = $("#tt"); 

    $.ajax(
    { 
     type:"POST", 
     url:"ajax.php", 
     data:frm.serialize(), 
     sucess:function (data) 
     { 
      $("#tt1").val(data); 
      alert('Success: '+data); ///---> this show alert with success and content 
     }, 
     error:function(a,b,c) 
     { 
      alert(c); //---> If error happen it will show alert(); 
     } 
    }); 

} 
</script> 
+0

nichts passiert keine Warnung –

+0

Überprüfen Sie Ihre Browser-Konsole. Es wird alle jquery Fehler darin –

+1

@Fairy eine Klärung von OP Anfrage wäre ein guter Kommentar Methinks, aber nicht beantworten Material. Wie auch immer, du kopierst auch den Tippfehler von OP. – YvesLeBorg

3

Sie einen Tippfehler Fehler anzeigt haben: sucesssuccess

+0

Danke Fehler gefunden –