Atozed Forums
ajax Call and rawtext - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: ajax Call and rawtext (/thread-1238.html)



ajax Call and rawtext - joel - 09-13-2019

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.


RE: ajax Call and rawtext - joel - 09-13-2019

The last line should read.

As I said before if the text is just words without the html tags then it works as expected.


RE: ajax Call and rawtext - Alexandre Machado - 09-14-2019

Hi Joel,

I'll have a look and let you know ASAP


RE: ajax Call and rawtext - Alexandre Machado - 09-14-2019

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?


RE: ajax Call and rawtext - joel - 09-14-2019

(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;
}