在ajax成功返回后重新加载jQuery样式
示例代码:
$.ajax({
type: "POST",
url: "example.php",
data: { name: "John", location: "Boston" },
success: function(response) {
//重新加载jQuery样式
$('head link[href="main.css"]').remove();
$('').appendTo('head');
//处理响应数据
console.log(response);
}
});
在ajax成功返回后,首先移除原先加载的jQuery样式,然后使用$('').appendTo('head')
重新加载样式文件。这样就能保证在ajax完成后,jQuery样式能够正常显示。
下一篇:ajax调用后模态框显示为空白。