Jose_49 Posted December 14, 2012 Share Posted December 14, 2012 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})[/CODE] But what I want is the following: [CODE]$.get('http://thepath.to/my/site/and/file.php', function(data){ var content_s = $(data).find('#cds_global'); $('#dlm_btn_settings').html(content_s)});[/CODE] 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 Link to comment Share on other sites More sharing options...
0 threetonesun Posted December 14, 2012 Share Posted December 14, 2012 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. Jose_49 1 Share Link to comment Share on other sites More sharing options...
0 Jose_49 Posted December 14, 2012 Author Share Posted December 14, 2012 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! Link to comment Share on other sites More sharing options...
0 Jose_49 Posted December 14, 2012 Author Share Posted December 14, 2012 When calling .load() using a URL without a suffixed selector expression' date=' 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');[/CODE] However, in the following case, script blocks in the document being loaded into #b are stripped out and not executed: [CODE]$('#b').load('article.html #target');[/CODE] [/quote'] :D. I made it work. I just pinpoint it directly without grabbing the portion I wanted! [CODE]$('#dlm_btn_settings').load('http://where.my/file/resides/file.php.php');[/CODE] Thanks a lot threetonesun!!!! :D threetonesun 1 Share Link to comment Share on other sites More sharing options...
Question
Jose_49
Hi people. I know, after some Googling, that it is possible to manipulate a loaded content through Ajax and interact with it, with:
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)
});
[/CODE]
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
Link to comment
Share on other sites
3 answers to this question
Recommended Posts