ユーザーが名を入力したことを検証するという簡単なタスクがあります。これはほとんどのブラウザーで機能しますが、chrome は ajaxfirstname.php から応答を得ていないようです。スクリプトは次のとおりです。
jQuery(document).ready(function () {
var validatefirst_name = jQuery('#validatefirst_name');
jQuery('#first_name').keyup(function () {
var t = this;
if (this.value != this.lastValue) {
if (this.timer) clearTimeout(this.timer);
validatefirst_name.removeClass('error').html('<span style="margin-left: 5px;"><img src="images/loader.gif" height="16" width="16" /></span>');
this.timer = setTimeout(function () {
jQuery.ajax({
url: "ajaxfirstname.php",
data: "action=check_first_name&first_name=" + t.value,
dataType: "json",
async: false,
type: "post",
success: function (j) {
validatefirst_name.html(j.msg);
}
});
}, 200);
this.lastValue = this.value;
}
});
});
そして私のhtml
<label for="first_name">First Name</label>
<input id="first_name" name="first_name" type="text" id="first_name" value="<?php
$name = explode(' ',$this->my->name);
echo $name[0];
?>">
<span id="validatefirst_name"></span>
開発者ツールを開きましたが、この特定のスクリプトでエラーは表示されません。これに関する提案はありますか?上記のコードは正しいように見えますか? Chromeに問題はありますか?前もって感謝します。