首先使用响应时正确格式化jQuery .load函数

Correctly format the jQuery .load function when using a response first

本文关键字:格式化 jQuery load 函数 响应      更新时间:2023-09-26

我不知道如何正确格式化.load函数与我正在做的。

一切工作正常,如果我提供的URL,但不能得到它的工作没有错误时,首先使用响应。

方法如下:

$("#postholder #" +response.postid).load("viewbuild.php?id=22 #" +response.postid, function() {

但是我不想直接给出URL,我想使用一个返回的URL。

理想情况下是这样的:

$("#postholder #" +response.postid).load(response.pageurl "#" +response.postid, function() {

我也试过这个:

$("#postholder #" +response.postid).load(response.pageurl + "#" +response.postid, function() {

这在某种意义上是有效的,但不加载指定的div,而只是加载整个页面。

但这当然不起作用。谁能告诉我该怎么做?

在工作示例中,url和标签(#)/id之间有一个空格。试一试:

$("#postholder #" +response.postid).load(response.pageurl + " #" +response.postid, function() {

您缺少+号

$("#postholder #" +response.postid).load(response.pageurl + "#" +response.postid, function() {});

在这种情况下,你可以尝试以下操作首先加载所有html然后使用find as follow

获取你的特定div
$("#postholder #" +response.postid).load(response.pageurl, function() {});
var divHtml =$("#postholder #" +response.postid).find("#" +response.postid);