php - I can't get to the success block of my jquery function -
i little stuck on jquery function below.
here situation:
1) php returns valid json
- can test when change $_post
$_get
, manually pass through data url.
2) function below works correctly right $.ajax
part.
3) function returns ready state 0
let me know if need anymore data. days of going on stack overflow , other forums has helped insight, can not seem fix in instance.
//html <form class="login-form" method="post"> <input type="text" id="name" name="name" value="" placeholder="username" required="yes"> <input type="password" id="pwd" name="pwd" value="" placeholder="password" required="yes"> <input type="submit" id="login" name="login" value="login" class="loginbutton" > </form> //javascript $('#login').click(function(event) { //event.preventdefault(); var u = $('#name').val(); var p = $('#pwd').val(); console.log(u, p); console.log("i seeing function?"); $.ajax({ contenttype: "application/json; charset=utf-8", cache: false, type: "post", url: "functions/login.php", data: {name:u, pwd:p}, datatype: "json", error: function(msg) { console.log("rs - "+msg.readystate); console.log(msg); }, success: function(msg) { console.log("rs - "+msg.readystate); console.log(msg); $.each( msg, function( i, val ) { console.log(val[0].session); //session variable in json string }); console.log("success block"); } }); });
datatype -> datatype problem, , if not try out 'text' type. maybe php server send out other lines messes things.
Comments
Post a Comment