且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JQuery的/ AJAX:加载外部的div使用动态内容

更新时间:2023-09-29 19:13:16

我不知道你是否已经解决了这一点,但我很惊讶没有人提到使用AJAX()函数。

I'm not sure if you've solved this already, but I'm surprised no one's mentioned to use the ajax() function.

这将允许您定义请求类型GET:

This would allow you to define the request type as GET:

function loadContent(id) {

    $.ajax({
    	type: "GET",
    	url: "external.php",
    	dataType: 'html',
    	data: {param: id},

    	success: function(html){
                 $("#container").html(html);
    	},

    	error: function(){
    	},

    	complete: function(){
    	}
    });

}

就在调用此函数,而不是使用负载。显然,你必须用code修补(主要是什么内容可以被成功函数)一点点,但是这应该给你一个很好的起点。

Just call this function instead of using load. Obviously you'll have to tinker with the code (mainly what goes in the success function) a little, but this should give you a good starting point.