Jquery Ajax调用后页面中断
我已经使用Ajax为我的公文包实现了多级过滤器,我的公文包是一个可扩展的div,它将使用jQuery代码运行Jquery Ajax调用后页面中断,jquery,ajax,Jquery,Ajax,我已经使用Ajax为我的公文包实现了多级过滤器,我的公文包是一个可扩展的div,它将使用jQuery代码运行 $(function() { Grid.init(); }); 相关代码 var Grid = (function() { // list of items var $grid = $( '#og-grid' ), // the items $items = $grid.children( 'li' ),
$(function() {
Grid.init();
});
相关代码
var Grid = (function() {
// list of items
var $grid = $( '#og-grid' ),
// the items
$items = $grid.children( 'li' ),
// current expanded item's index
current = -1,
// position (top) of the expanded item
// used to know if the preview will expand in a different row
previewPos = -1,
// extra amount of pixels to scroll the window
scrollExtra = 0,
// extra margin when expanded (between preview overlay and the next items)
marginExpanded = 10,
$window = $( window ), winsize,
$body = $( 'html, body' ),
// transitionend events
transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
'OTransition' : 'oTransitionEnd',
'msTransition' : 'MSTransitionEnd',
'transition' : 'transitionend'
},
transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
// support for csstransitions
support = Modernizr.csstransitions,
// default settings
settings = {
minHeight : 350,
speed : 350,
easing : 'ease'
};
function init( config ) {
// the settings..
settings = $.extend( true, {}, settings, config );
// preload all images
$grid.imagesLoaded( function() {
// save item´s size and offset
saveItemInfo( true );
// get window´s size
getWinSize();
// initialize some events
initEvents();
} );
}
Ajax调用
// AJAX update
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'update':
require __DIR__ . '/portfolio--results.php';
break;
}
die( 0 );
}
function update_results() {
var $form = $(this).parents("form");
var data = $form.serializeArray();
data.push({
name: "action",
value: "update"
});
$.ajax({
type : "GET",
data : data,
success : function(response) {
$(".search-results").html(response);
}
});
}
事件侦听器
$(document).on("click", "menu:not(:last-child) input", update_results);
$(document).on("click", "menu:not(:first-child) input", update_results);
页面运行良好,直到我使用Ajax加载数据,公文包功能将中断。
我知道有一种方法可以委托jQuery代码来解决Ajax问题,但我对jQuery不太熟悉,有人能帮我解决这个问题吗
我将代码复制并粘贴到Ajax正在加载的页面上,该广告只运行一次,在选择更多过滤器后就会中断。我没有看到Ajax调用。我看到一些PHP@Smeegs只是更新它