I need to replace the content of a div in my page with the html resultant from an ajax call. The problem is that the html have some necessary scripts in it and it seems that
I had the same problem, but with more issues which I couldn't fix that easily. But I found a solution:
This is my pseudo-source (HTML) that I couldn't change in any way.
I used $.get() to fetch this HTML page.
Now that I have the code as a string, it's time to search in it with jQuery.
My aim was, to isolate the Javascript-Code inside the -Tag, that belongs to the DIV identifier2, but not to identifier1. So what I wanted to get is bar(456) as a result string.
Due to the reason, that jQuery strips all script-Tags, you cannot search like this anymore:
var dom = $(data); //data is the $.get() - Response as a string
var js = dom.filter('div#identifier2 script').html();
The solution is a simple workaround. In the beginning we will replace all -Tags with something like :
var code = data.replace(/(