4 posts in this topic

Posted

Hi people. I know, after some Googling, that it is possible to manipulate a loaded content through Ajax and interact with it, with:


$(document).ajaxComplete(function(){

	// fire when any Ajax requests complete

})

But what I want is the following:

$.get('http://thepath.to/my/site/and/file.php', function(data)

{

  var content_s = $(data).find('#cds_global');

  $('#dlm_btn_settings').html(content_s)


});

I want to load a page. From that page, I would like to get a specific <div> hence the ".find" function.

Now, from that <div> whose ID is "cds_global" (Without quotes), I would like to get ALL HTML + JavaScript functionality.... How do I do that?

Edit: BTW, thanks a lot in advanced :p

Share this post


Link to post
Share on other sites

Posted

Try to specify dataType in the get request as html:

dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html)

Also, I believe if you use .load() and specify the div, it will run scripts in that div. If all you're doing with the data returned is pulling out a single div, .load() is the better call to use.

1 person likes this

Share this post


Link to post
Share on other sites

Posted

Try to specify dataType in the get request as html:

Also, I believe if you use .load() and specify the div, it will run scripts in that div.

Let me try that out!

Share this post


Link to post
Share on other sites

Posted

When calling .load() using a URL without a suffixed selector expression, the content is passed to .html() prior to scripts being removed. This executes the script blocks before they are discarded. If .load() is called with a selector expression appended to the URL, however, the scripts are stripped out prior to the DOM being updated, and thus are not executed. An example of both cases can be seen below:

Here, any JavaScript loaded into #a as a part of the document will successfully execute.


$('#a').load('article.html');

However, in the following case, script blocks in the document being loaded into #b are stripped out and not executed:

$('#b').load('article.html #target');

:D. I made it work. I just pinpoint it directly without grabbing the portion I wanted!

$('#dlm_btn_settings').load('http://where.my/file/resides/file.php.php');

Thanks a lot threetonesun!!!! :D

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.