【发布时间】:2010-12-02 02:17:12
【问题描述】:
我正在阅读jQuery load documentation,它提到我可以通过将额外参数作为字符串传递来使用 load 来执行 GET 请求。我当前使用参数作为键/值对的代码是:
$("#output").load(
"server_output.html",
{
year: 2009,
country: "Canada"
}
);
以上工作正常,但这是一个发布请求。如何修改上述内容以在仍然使用 load 的同时执行 GET 请求?
【问题讨论】:
-
用 $.param() 包围你的数据对象 $("#output").load("server_output.html", $.param({year: 2009, country: "Canada"}) );
-
@BastiaanLinders 您应该将此标记为完整答案。它应该与未描述如何创建参数字符串的已接受答案结合使用。
标签: jquery parameters load http-get