2013-06-03 66 views
0

不工作我已經驗證用戶的簡單的任務已經進入了第一個名字。這在大多數瀏覽器中都有效,但chrome似乎沒有得到ajaxfirstname.php的響應。下面是該腳本:jQuery的AJAX表單驗證鉻

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會有任何問題嗎?提前致謝。

回答

0

可能是在文本框中的,因爲你已經使用的ID兩次[ 「ID =」 FIRST_NAME 「請改變這一點,讓我知道..

ID =」 FIRST_NAME 「NAME = 」FIRST_NAME「 TYPE =」 text「id =」first_name「 value =」my-> name);