我有一个示例代码:
<input type="text" class="" id="key" name="key" value="ex: IPhone 4S"
onfocus="cleanPhoneBox(this);"
onblur="fillPhoneBox(this);"
onkeyup="javascript:search_phones('demo.php');">
和 javascript
function cleanPhoneBox( obj ) {
if( obj.value == obj.defaultValue ) {
obj.value = '';
obj.className = '';
}
}
function fillPhoneBox( obj ) {
if( obj.value == '' ) {
obj.value = obj.defaultValue;
obj.className = 'search_tool_tip';
}
}
var lasttimeout = 0;
function search_phones(ajaxdomain) {
search_string = $('#key').val();
if(search_string.length >= 2) {
if( lasttimeout ) clearTimeout(lasttimeout);
lasttimeout = setTimeout('search_phones_call(\"'+ajaxdomain+'\", \"'+search_string+'\")', 300 );
}
}
function search_phones_call( ajaxdomain, search_string ) {
$('#searchPhoneResultsContainer').empty();
$.ajax({
type:"GET",
url : ajaxdomain + '?jsoncallback=?',
data: {
action: "dialog",
type: "searchPhonesJSON",
query: search_string,
itemsCount: 100,
nocache: 96316638
},
dataType:'json'
});
}
当我用关键字搜索时:“ iphone 4
”是结果调用json ajax OK,但是当delete keyword
,并且search again
是结果不能调用ajax json 回调时,如何解决它