我想,當用戶使用搜索textbox
更新我div
內容與新的內容:jQuery的AJAX:未捕獲的SyntaxError:意外的標記
$('#business_request_filter_search_textbox').on('input propertychange paste', function() {
$.ajax({
url: "/ajax/housekeeping/business/" + $("#search_filter_selection")[0].selectedIndex == 1 ? "get-requests-by-username" : "get-requests-by-business-name";
type: "GET",
cache: false,
data: { search: $('input#business_request_filter_search_textbox').val() },
beforeSend: function(xhr) {
$('#request_area').html('<center>Please wait while we gather results...</center>');
},
success: function(data) {
$('#request_area').html(data);
},
});
});
現在我有一個下拉列表中選擇他們想要來過濾搜索什麼通過,用戶名或企業名稱。這是拋出錯誤的線。
url: "/ajax/housekeeping/business/" + $("#search_filter_selection")[0].selectedIndex == 1 ? "get-requests-by-username" : "get-requests-by-business-name";
我做錯了什麼?
你檢查這個'$( 「#search_filter_selection」)[0] == .selectedIndex 1? 「get-requests-by-username」:「get-requests-by-business-name」條件? –
may try($(「#search_filter_selection」)[0] .selectedIndex == 1)? 「get-requests-by-username」:括號中的「get-requests-by-business-name」 –