如何使用过滤器从URL加载div

时间:2019-05-18 07:36:15

标签: javascript html

这是我在这里的第一个问题,对不起,如果我做错了事。

我正在尝试从网站上的外部URL加载内容。 我在堆栈上找到了以下代码:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){

   $('#content').load("new.html #div");

});
</script>

它工作正常,但是当我尝试使用过滤器从更复杂的URL加载内容时会出现问题: http://example.com/oferty/lista/?adv_filter_city&adv_filter_purpose=oferta-wynajmu&adv_filter_type=domy&yardageStart&yardageEnd&adv_filter_numroomStart&adv_filter_numroomEnd&adv_filter_price_min&adv_filter_price_max&submit=Szukaj

该代码仍然有效,但是它从以下位置加载内容: http://example.com/oferty/lista/ 并忽略URL中的所有过滤器。 我也尝试过这种解决方案:

 $.ajax({
   url:href,
   type:'GET',
   success: function(data){
       $('#oferty').html($(data).find('#div').html());
   }
});

但结果相同-获取内容,但忽略过滤器。事实是,带有过滤器的URL上的内容与没有过滤器的URL上的内容是不同的,我需要抓住带有过滤器的URL。

是否有解决方案可以显示完整网址中的内容,而不忽略过滤器?

提前谢谢!

0 个答案:

没有答案