A seriously problematic and retarded software program which passes the title of "Joomla" is giving me its usual load of head aches.

Sample code

I've the next code:

....
<div id="abc"><!----></div>
<script type="text/javascript">
    jQuery.get(url,function(data){
        jQuery('#abc').html(data);
    },'data');
</script>
....

And That I understand this code from that url:

....
<script type="text/javascript">
   document.write('<span');
   // perhaps write classes
   document.write('>');
   // and the rest of the code
</script>
....

The Problem

Joomla has been modern by utilizing document.write snipets. This completely obliterates any AJAX html, unless of course I disable/strip out javascript, the industry huge NO.

The Fix

I have to replace the written textOrsignal progressively to appear like:

<span id="ob1"><!----></span>
<script type="text/javascript">
   _ob_begin(1);
   _ob_write(1,'<span');
   // perhaps write classes
   _ob_write(1,'>');
   // and the rest of the code
   _ob_end(1);
</script>

Clarification

Joomla-enthusiasts, do not get anywhere near this subject. I seem like burning a joomla dev alive at this time.

The produced code (document.write) is strictly joomla's doing...no plug ins, components or anything.

One of the ways is always to perform a find and replace using Developers Notepad 2 on all files for the reason that folder that finish insjs. This may help accomplish "unless of course I disable/strip out javascript, the industry huge NO."

You'll be able to overwrite document.write with your personal function that buffers output text and following a delay creates it with a element's innerHTML. This is not wholly reliable however it can catch many common cases.

However, you cannot load <script> content by writing it with innerHTML/html()). jQuery's load() tries to deal with a few of the problems, but it is essentially damaged, even before the issues with document.write (that is indeed filthy).

You could attempt to create this content to innerHTML, choose the script elements, replace all of them with empty divs, and eval() their text (this really is type of what load() attempts to do, not necessarily effectively), with document.write overridden to throw completed output towards the div. But it will likely be untidy and hard to rely on. I'm not sure what your use situation is, but there's probably a much better approach than this.

Personally, i wouldn't use Joomla, basically needed to I'd most likely go seek within the code to locate that bit of code and destroy it with my laser gun.

But, a fast 'n' dirty fix may be output buffering in PHP, this can be used to trap the whole items in a webpage, do your miracle inside, after which output it towards the browser. So inside your situation, you could utilize it to locateOrsubstituteOreliminate the document.write's.

Will I advise this method? No, but when you actually can't touch the produced code (and that i wouldn't know, so having faith in your judgement), you do not have several choices left.