Combine Ajax content loader with editor

This function places 'Hello World' inside my rich text editor (TinyMCE)

      function ajaxLoad() {
      var ed = tinyMCE.get('elm1');
      ed.setContent('Hello World');
      }

This line of code places the content of test.php into an empty div
      ajax_loadContent('divID','external/info.php');

How can I combine these, so that I can place the content of test.php into the editor?

This does NOT work:
      function ajaxLoad() {
      var ed = tinyMCE.get('elm1');
      ed.setContent(ajax_loadContent(ed,'external/info.php'));
      }
edit.zip
LVL 16
hankknightAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pellepCommented:
TinyMCE doesn't really work that way. When you initialize the editor instance, it replaces the div/textarea so you're not supposed to interact with the content outside of the tinyMCE framwork.

Try this and see if it works
 
function ajaxLoad() {
var ed = tinyMCE.get('elm1');
ajax_loadContent(ed.getElement() ,'external/info.php')); // set content on underlying div
ed.load(); //reload editor from underlying div
      }

Open in new window

0
pellepCommented:
Sorry, typo in the above.

Also, this assumes that you created the TinyMCE editor instance from a <div> (not a <textarea>) and the ajax_loadContent assumes an id of a <div>
function ajaxLoad() 
{
var ed = tinyMCE.get('elm1');
ajax_loadContent(ed.getElement() ,'external/info.php'); // set content on underlying div
ed.load(); //reload editor from underlying div
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hankknightAuthor Commented:
Thanks, pellep.

Your answer had two parts.

You explained that the content in the editor iframe MUST be reloaded after this is done.

And you explained that the code presumes the content is in a div, not a textarea.

I have asked a related question here:

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23898620.html
0
whspiderCommented:
Hi hankknight,

i am in need of the same...can u give me the link from where you got this editor....i to want to load
different values to the editor based on a select ooption uisng ajax
0
hankknightAuthor Commented:
whspider, I do not understand what you need.  The editor is TinyMCE.
http://tinymce.moxiecode.com/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.