Json : My code is not working
Dear All
I always fail using this JSON
My JQUERY
- <script language="javascript">
$(document).ready(function($) {
$("#loginid").blur(function() {
if($.trim($("#loginid").val()) =='' )
{
$("#loginid").val('');
alert("login id cannot be blank");
}
else
{ var lid=$.trim($("#loginid").val());
if(lid.indexOf('@') === -1) // check whether the email id has @ sign ==> works fine
{
alert("Enter email ID only");
}
else
{
var lid=$("#loginid").val();
alert($("#loginid").val()); // Confirms the email id entered is correct ==> value is OK
-
//JSON CODE
- $.getJSON("loginidcheckfill.php", {id: $("#loginid").val()}, function(data){
$('#namediv').html(data['name']);
$('#courseiddiv').html(data['courseid']);
});
}
}
});
}).fail(function(){
alert("OUCH!")
});
</script>
Html
- <table width="100%%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="11%" height="47" > </td>
<td width="16%" >Login(Email Iid)</td>
<td width="73%"><input name="loginid" type="text" id="loginid" size="45" /> </td>
</tr>
<tr>
<td height="46"> </td>
<td colspan="2" class="text16bdarkgreen"><table width="100%%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="19%" class="text11btop" id="courseiddiv" > </td>
<td width="33%" id='forgotpassword' style="cusrsor:pointer; font-family: 'Homenaje', serif;font-weight: 400; color:#212121; font-size:18px ">Forgot Password</td>
<td width="19%"><a href="register.php"><span style=" font-family: 'Homenaje', serif;font-weight: 400; color:#900; font-size:18px ">Register me</span></a></td>
<td width="29%" class="text11btop" id="namediv"> </td>
</tr>
</table></td>
</tr>
</table>
My PHP code
- <?php
session_start();
//liginidcheckfill.php
include_once("includes/dbconnect.php");
include_once("functions.inc.php");
if(isset($_GET['id']))
{
$sql = mysql_query(sprintf("select * from member where email1='%s'",intval($_GET['id'])));
if(mysql_num_rows($sql))
{
$data = mysql_fetch_array($sql);
echo json_encode($data);
}
}
?>
I tried
- select * from member where email1='myemailid@domain.com'"
which is working fine
Cannot get the values in
Pls advise
Million Thanks in advance
Actually used this sort of code earlier but I donot understan what is going wrong