Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ajax Call and rawtext
#1
iw15.1.4

I have incorporated the Monaco editor (the same editor that runs vs code) into an iw application using the ajaxCall function.

Everything works nicely when i use normal words.   However, when I try to pass html data back to IW, then I get an error.

How would I pass back "raw" text using the ajaxCall function?   Do I need to wrap it in something?


Here is the example.

First here is my function call on the onclick

function (e){

ajaxCall("ajaxSaveCode",
        "&code='"+monaco.editor.getModels()[0].getValue()+"'",
        false,
        function(response){                             
});

return true;
}

If I try to send the following text back to IW then I get an error.

<html>
<body>
    <h1>Test Header</h1>
</body>
</html>



The error that I get says

127.0.0.1:8888 says
Ajax request failed: The application server did not respond.

URL:/21341234213/$/callback?
callback=ajaxSaveCode&code='<html>
<body>
  <h1>Test header</h1>
</body>
</html>'&. . . . .

As I said before if the text is just words with the html tags then it works as expected.
Reply
#2
The last line should read.

As I said before if the text is just words without the html tags then it works as expected.
Reply
#3
Hi Joel,

I'll have a look and let you know ASAP
Reply
#4
I created a simple test case here and seems to be working as expected.

Can you please test it? What is different, compared to yours?


Attached Files
.zip   NewCallback.zip (Size: 52.57 KB / Downloads: 18)
Reply
#5
(09-14-2019, 12:46 AM)Alexandre Machado Wrote: I created a simple test case here and seems to be working as expected.

Can you please test it? What is different, compared to yours?

The example helped get me on the correct path to the answer.   in addition to the html that I posted in this forum there were other characters that caused the posting to fail like {% that I was using in the templates.   The solution for it was to wrap the html content in encodeURIComponent so that it would pass back the information as encoded.    

Thanks for the help.

Here is the final call for anyone else that is trying to solve this issue.

function (e){

ajaxCall("ajaxSaveCode",
        "&code="+encodeURIComponent(monaco.editor.getModels()[0].getValue()),
        false,
        function(response){                             
});



return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)