我使用的autosuggest插件允許我從下拉菜單(demo here)中選擇多個項目。我希望將查詢發送到一個php文件(我將在以後專注於查詢本身),並在不離開頁面的情況下返回結果。發送此數組到PHP並獲得結果在div(FCBKcomplete)
php文件,現在幾乎是空的:
<?php print_r($_REQUEST); ?>
但我知道我犯了一個錯誤與我的jQuery的地方,因爲在搜索框中不displaying properly anymore。
這裏是我建立的代碼,我不知道要放在「數據」字段中。
<script type="text/javascript">
$(document).ready(function(){
$("#select3").fcbkcomplete({
json_url: "data.txt",
addontab: true,
maxitems: 10,
input_min_size: 0,
height: 10,
cache: true,
newel: false,
filter_selected: true,
maxitimes: 5,
// I did this
onselect:"get_venue",
});
// I also did this
function get_venue() {
$("#select3 option:selected").each(function() {
$.ajax({
type: 'POST',
url: 'post.php',
dataType: 'json',
data: {
WHAT DATA GOES HERE?
},
success : function(data){
$('#phpmessage').removeClass().addClass((data.error === true) ? 'error' : 'success')
.text(data.msg).show(500);
if (data.error === true)
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
$('#waiting').hide(500);
$('#phpmessage').removeClass().addClass('error')
.text('There was an error.').show(500);
}
});
});
}
});
</script>
抱歉,對於如此長的帖子大家:)!謝謝:))
錯誤我越來越:
不是一個函數:返回func.call(FUNC,_object);
function funCall(func, item) {
var _object = {};
for (i = 0; i < item.get(0).attributes.length; i++) {
if (item.get(0).attributes[i].nodeValue != null) {
_object["_" + item.get(0).attributes[i].nodeName] = item.get(0).attributes[i].nodeValue;
}
}
return func.call(func, _object);
}
function checkFocusOn() {
if (focuson == null || focuson.length == 0) {
return false;
}
return true;
}
控制檯中的任何錯誤? –
是的,'這裏有什麼數據?'。我故意把它放在那裏,因爲我真的不知道應該發送什麼數據:/ – user944589