开发者

Loading a specific div from a page using .ajax

开发者 https://www.devze.com 2023-03-18 14:37 出处:网络
I need to load the contents of a div residing on a page inside my website into a div that is shown in Fancybox. Basically, I\'m loading a reservation form into a div and showing the whole thing with f

I need to load the contents of a div residing on a page inside my website into a div that is shown in Fancybox. Basically, I'm loading a reservation form into a div and showing the whole thing with fancybox. I can't use the .load() function because it strips out all the script tags that validate the form, etc. I'm trying to use the .ajax() function to grab all the html including script tags and other jquery references.

Here's a snipit of what I'm working with:

$.ajax({
url: eventUrl,
dataType: 'html',
success: function(data) {           
var include = $(data).filter($('#bookingFormWrapper'))
alert(inclu开发者_运维知识库de);                 
}
});

The Ajax call here is using a variable to get the url of the page where the detail lives. I need to add the contents of #bookingFormWrapper to a div called #detailView. I'm using alert for testing purposes only. I can't seem to grab just the contents of #bookingFormWrapper. Any help is appreciated!


it's easier if you use .load, like ...
$("#detailview").load(eventUrl + " #bookingFormWrapper")


Have you tried $('#bookingFormWrapper').innerHtml() or $('#bookingFormWrapper').html() ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号