javascript - Login using ajax and php -


I had a problem when I wanted to login to AJAX, but no answer !! Div error does not show any message (success or failure).

The html code is:

  & lt; Script src = "http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script> & Lt; Script type = "text / javascript" charset = "utf-8" src = "http://cdn.app-framework-software.intel.com/2.0/appframework.ui.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; Function login () {var par = "username =" + $ ('# username'). Val () + "& password =" + $ ('# password'). Val (); // window. Alert (equals); Printed $ .ajax ({type: 'POST', url: 'login.php', data: {username: $ ('# username'). Val (), password: $ ('# password'). ()}, Success: function (response) {$ ('# error'). Html (response);}}); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; Username: & lt; Input type = "text" id = "username" /> gt; & Lt; Br> Password & lt; Input type = "password" id = "password" /> & Lt; Br> & Lt; Button onclick = "login ()" & gt; Login & lt; / Button & gt; & Lt; Br> & Lt; Label id = 'error' & gt; HH & lt; / Labels & gt; & Lt; / Body & gt;   

There is no error in the login.php code and get the results properly but problem in AJAX code

  $ qry = "Choose username, User WHERE user name with password = '$ uName' and password = '$ pWord' "; $ Race = mysql_query ($ qry); $ CheckUser = mysql_num_rows ($ race); If ($ checkusor> gt; 0) {resonant "success"; } Else {echo "unsuccessful"; }? & Gt;    

I've checked your code and found that it's working.

Please check the htmlcode file and the login file is present at the same level on the root.

If you still face the problem, save the HTML file as a php and try again.

Comments

Popular posts from this blog

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

sql - PostgreSQL automatically update row at specific date -

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -