私は
<p id="err_output"></p>
私のページでは、このjavascriptにリンクされています:
$(document).ready(function($) {
$("#username").on('keyup',check_username_existence);
});
機能は次のとおりです。
function check_username_existence(){
$.ajax({ url: './php/user_name_availability.php',
data: { username : $('#username').val() },
type: 'post',
success: function(output) {
var json = $.parseJSON(output);
$('#err_output').html(json.response.exist);
if(json.response.exist == 'true'){
// $('#err_output').html('Exists');
}
}
});
};
json 応答の値は次のとおりです。
{ "response" : { "exist" : true } }
{ "response" : { "exist" : false } }
問題は、exist が true の場合にのみ出力されることです。
私が入れたら
$('#err_output').html( output + json.response.exist);
一方、偽の値も出力します。