+ 3

How to send ajax request in sololearn? I tried but it shows error everytime.

Ajax request in sololearn

19th Jan 2019, 6:20 AM
Sailesh Dahal
Sailesh Dahal - avatar
8 odpowiedzi
+ 5
Sailesh Dahal You are not allowed to change the master document's href/location/etc in the webviews here. If you want to get that kind of browsing behavior you can iframe it. Some sites block frames and you will have new and interesting CORS considerations but it does work (and it can be expanded to full-panel). Here's a sample where I manipulate a frame to expand it after an alignment issue is overcome: https://code.sololearn.com/WeN0W6xcgi3e/?ref=app That's just a reference; someone else here did the iframe capture better (using that site) but it's been a long time since I've seen that code. edit: Something changed --the security may not work anymore but the iframe stuff may still be useful.
19th Jan 2019, 4:56 PM
Kirk Schafer
Kirk Schafer - avatar
+ 4
Could you please supply the code that you tried, so that we can take a look at it? Also, note that SoloLearn does not have a public API yet, so a request would mmost likely result in an “access denied” error.
19th Jan 2019, 7:20 AM
Rowsej
Rowsej - avatar
+ 3
Sailesh Dahal Ok, your is not a CORS problem. You have to know that, always for security reasons, on many browsers, you can do only request to https served host if your original script is hosted on a https served host... In practice because your script is executed on sololearn.com that is served using https, you can make request only to an host that support https but you use the http protocol in request thought it support https protocol. Try to replace 'http' with 'https' and all will be ok 😉
19th Jan 2019, 9:19 AM
KrOW
KrOW - avatar
+ 2
Sailesh Dahal Its hard help you without some code but probably you encountered the classic CORS problem. In practice at any host, you can do ajax request only to that host for security reason except when the target host send to you the CORS response headers... Just try to search on google for futher explainations
19th Jan 2019, 8:56 AM
KrOW
KrOW - avatar
+ 2
I tried jQuery to send a GET request to an opensource API, and got a CORS, error , and when I tried using xhr, previously, I got the error too.
19th Jan 2019, 8:58 AM
Sailesh Dahal
Sailesh Dahal - avatar
+ 2
Sailesh Dahal Please, link some code for get a better help
19th Jan 2019, 9:04 AM
KrOW
KrOW - avatar
19th Jan 2019, 9:06 AM
Sailesh Dahal
Sailesh Dahal - avatar
+ 1
https://code.sololearn.com/Wy06asf2u5zu/?ref=app I was trying to to this sadly it only renders in desktop version of sololearn
19th Jan 2019, 9:40 AM
Sailesh Dahal
Sailesh Dahal - avatar