i have a script for jsonp as follows
<script>
$(document).ready(function(){
$("#LoginForm").submit(function(){
var data = $(this).serialize();
//alert(data);
$.ajax({
type:"POST",
dataType:"jsonp",
url:"https://akshay.tk/api/login.php",
data:data,
success:function(data)
{
/// WHAT TO WRITE HER TO GET PHP RESPONSE
/// DIV WHERE DATA TO BE SHOWN, ID IS RESULT
}
});
return false;
});
});
</script>
and my php code is
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
// login check for user
$result = mysqli_query($con,"SELECT * FROM `admin_login` WHERE `username`='$username' AND `password`='$password'");
if(mysqli_num_rows($result) > 0)
{
$user = mysqli_fetch_assoc($result);
// user found
$response["success"] = 1;
$response["uid"] = $user["id"];
$response["username"] = $user["username"];
$response["role"] = $user["role"];
echo json_encode($response);
}
Everything is going good and when i used developers tool then i came to know it is giving proper response as well. Response by php :
{"success":1,"uid":"1","username":"admin","role":"admin"}
What code should i write in jQuery SUCCESS function so that i can get php response?