Figured it out. It has to do with the usage of document.write() inside of the script tags. For example, inside of handle_bbcode_safe, this works:
And so does this:
Code:
return "<script language=\"javascript\" type=\"text/javascript\"> donothing(); </script>;
But this does not:
Code:
return "<script language=\"javascript\" type=\"text/javascript\"> document.write( decode64( '$fixed' ) ); </script>";
For some reason, using the write function here buggers it up when using AJAX. The solution is to modify some existing html instead. To do this, make a div to modify, and assign it a random id, then edit the innerHTML of it. It should look like this in the end:
Code:
$safeId = vbrand(1, 1000000);
return "<div id=\"safe_container_$safeId\"></div><script type=\"text/javascript\"> document.getElementById('safe_container_$safeId').innerHTML = decode64('$fixed'); </script>";
That should work!