small jquery issue..
I'm making a script that should load content from another page within the same domain. I've already done this but it's not working because it also loads 'script' tags and executes those scripts and it shouldn't be that way...
let me give you an example of what I already got.
url = 'http://domain.com/content.html';
$.get(url)
.success(function(happy){
content = $(happy).find('.content');
$('#element').append(content);
}) ok so I'm trying to load .content from (content.html) into #element BUT the problem is that content.html looks like this:
<div class="content"> <p>blah blah blah</p> <script>some_function(blah blah)</script> </div> <div class="content"> <p>blah blah blah</p> <script>some_function(blah blah)</script> </div> <div class="content"> <p>blah blah blah</p> <script>some_function(blah blah)</script> </div>
<div id="element"> <div class="content"> <p>blah blah blah</p> <script>some_function(blah blah)</script> </div> <div class="content"> <p>blah blah blah</p> <script>some_function(blah blah)</script> </div> <div class="content"> <p>blah blah blah</p> <script>some_function(blah blah)</script> </div> </div>
I have tried the following:
url = 'http://domain.com/content.html';
$.get(url)
.success(function(happy){
content = $(happy).find('#content-parent').html().replace(/<script/g,' ');
// side note: I know it doesnt remove the script but it kills it
$('#element').append(content);
}) Please if you know the solution to this let me know! I know it's probably something stupid that I forgot but it's driving me craaazy, I've been 1 hour thinking why is this happening but no ideas come to my mind

EDIT: I found the solution to this problem here: prevent jquery ajax to execute javascript from script or html response - Stack Overflow just in case anyone else have this same issue.
Now back to coding!
-
Richard Mortimer -
Thanks
SignatureFree Downloads - No Opt-In Required - Just Right Click Image: 1 - "Internet Marketing Crucial" MP3; 2 - Traffic MP3; 3 - Un-Blockable Pop-Up; 4 - EZ Set Up PayPal Payments Script{{ DiscussionBoard.errors[8618194].message }} -