index.js
$.ajax({
url: 'php_action/getSelectedMember.php',
type: 'post',
data: {member_id : id},
dataType: 'json',
success:function(response) {
$("#Number1").text(response.num1);
)}
index.php
<?php
$var="10";
$result='<p id="Number1"></p>';
echo gettype($result) , gettype($var); //string,string
echo "$result $var"; // 10,10
if ($result == $var) {
echo "OK!";
}
?>
value Number1
is 10, and variables $var
and $result
are the type of string. does not work if statement in index.php? Is there another way to get id Number1
value?
<?php
$var="10";
$result='<p id="Number1"></p>';
echo gettype($result) , gettype($var); //string,string
echo "$result $var"; // 10,10
if ( strcmp($result, $var) ){
echo "OK!";
}
?>
Problem in your index.php. when you use dataType JSON then first echo will return.try to avoid echo. '< p id="Number1">< / p >' will never equal "10" but you can try in this way, i think it will help you.
<?php
$var='10';
$result='10';
$array = array();
if ($result == $var) {
$array['msg'] = 'OK!'
}
header('Content-Type: application/json');
echo json_encode($array);
?>