javascript - Cannot detect json_encode result from mysql in ajax success -


i trying json response in success ajax mysql.
error getting in console -> uncaught syntaxerror: unexpected token <

my ajax code.

    function getmessage(siteid)     {        document.getelementbyid("add").disabled = true;     $.ajax({         type: "post",                        url: "checksite.php",            data: { siteid : siteid }, //6 digit number         success: function(data) {             alert(data);             var obj = jquery.parsejson(data);             if(objdata.status == "not available"){                 alert("not available");                 document.getelementbyid("add").disabled = false;             }             if(objdata.status == "available"){                 alert("available");                 document.getelementbyid("add").disabled = false;             }         },         error: function(result){             alert("error");         }     });  } 

my checksite.php

$siteid = $_post['siteid'];  if($siteid !=''){    $sql = "select *  tablename siteid='$siteid'";    $result2 = mysql_query($sql);    if(mysql_num_rows($result2) > 0){                echo json_encode(array('status' => 'not available'));    }    else{                 echo json_encode(array('status' => 'available'));    }          } 

its showing me parse error. jquery.parsejson(data) not @ working.

there syntax error on line

data: { siteid : siteid } 

add comma @ end

data: { siteid : siteid },                          ^ 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -