Jump to content



Photo

  • Please log in to reply
3 replies to this topic

#1 Jose_49

Jose_49

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 30-July 09

Posted 14 December 2012 - 17:40

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


#2 threetonesun

threetonesun

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 26-February 02

Posted 14 December 2012 - 17:44

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.

#3 OP Jose_49

Jose_49

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 30-July 09

Posted 14 December 2012 - 17:45

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!

#4 OP Jose_49

Jose_49

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 30-July 09

Posted 14 December 2012 - 18:02

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



Click here to login or here to register to remove this ad, it's free!