我不能为了我的生活找出为什么这不起作用。一直工作太久,需要一套新的眼睛。表单提交上的JQuery AJAX不起作用
我可以调用alert("Error: City not found. Please try again.");
和alert("Error: City too ambiguous, please try again.");
但这并不提交表单!不知道为什么。在此先感谢您的帮助。
//why won't this submit the form???
if (codes.length == 1) {
$('#city_number').val(codes);
return true;
}
$('#real-estate-search').submit(function() {
//users won't always click the drop down, so we need to have a best
//guess script which guesses which city the customer wants.
//get the radio status
radio_selection = $('input[name=search_type]:checked', '#real-estate-search').val();
if(radio_selection == 'city' && !$('#city_number').val()
&& $('#search_query').val()) {
alert("if fired!");
$.ajax({
type: "GET",
url: "includes/autocomplete.php",
data: "query="+ $('#search_query').val(),
success: function(data){
alert("ajax success!");
return_data = jQuery.parseJSON(data);
codes = return_data.data;
error = null;
if (codes.length == 0) {
alert("Error: City not found. Please try again.");
return false;
}
if (codes.length > 1) {
alert("Error: City too ambiguous, please try again.");
return false;
}
if (codes.length == 1) {
$('#city_number').val(codes);
return true;
}
}
}); //end of ajax function
} else return true;
return false;
});
'$('#real-estate-search')''form'或'input'的类型是什么 – mgraph 2012-02-09 12:39:40