我想将外部ajax内容(不是.php但.aspx文件)加载到div中,如何使用asp.net ajax执行此操作,jquery ajax解决方案也将受到赞赏,谢谢!
答案 0 :(得分:2)
参见这篇文章:
Using jQuery to directly call ASP.NET AJAX page methods
public partial class _Default : Page
{
[WebMethod]
public static string GetContent()
{
return "your content";
}
}
$.ajax({
type: "POST",
url: "Default.aspx/GetContent",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$('#yourdiv').html(msg.d);
}
});
使用.load:
$('#yourdiv').load('default.aspx/GetDate', function() {
//done
});