Logic Machine Forum
Getting data from .lp script - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Getting data from .lp script (/showthread.php?tid=865)



Getting data from .lp script - buuuudzik - 22.06.2017

Hello guys,

I am preparing a few html pages but for saving memory I want prepare them fully on my PC and after tests I will upload them to LM.

Maybe somebody knows how can I connect my local page with lm .lp file?

I've tried something like this:
Code:
<!DOCTYPE html>
<html lang="en">
 <head>
   <meta charset="utf-8">
   <title>title</title>
   <script  src="https://code.jquery.com/jquery-3.2.1.min.js"  integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="  crossorigin="anonymous"></script>
 </head>
 <body>
   
<script type="text/javascript">
$.get("LM_IP_ADDRESS/user/data.lp", function(data) {
 data = data.trim();
 data = JSON.parse(data);
 console.log(data);
});
</script>
</body>
</html>

But instead data I have nothing. And also no errorSad

I've also prepared some file which is a copy of a data which is generated via .lp file(json table) but then I have error:
~"Error in XML processing: syntax error" which is also very general error and I don't understand what is the problem .

The same is when I try only use $.get() for downloading very simple .txt and alert its source.


RE: Getting data from .lp script - Erwin van der Zwart - 22.06.2017

Hi,

You need same origin policy for that and send extra header, but the server side must be handling that extra header and it's not prepared for that.

So you can't do what you want to do, you must run .html and .lp on the same origin..

Running .lp also on your local pc would require LUA and other stuff on your local server so i don't think you want to go there...

https://en.m.wikipedia.org/wiki/Same-origin_policy

BR,

Erwin


RE: Getting data from .lp script - buuuudzik - 22.06.2017

(22.06.2017, 21:03)Erwin van der Zwart Wrote: Hi,

You need same origin policy for that and send extra header, but the server side must be handling that extra header and it's not prepared for that.

So you can't do what you want to do, you must run it on the same origin..

https://en.m.wikipedia.org/wiki/Same-origin_policy

BR,

Erwin

Also when I have in the same folder these 2 files:
- data.txt
- index.html.

And in index.html I am trying to download the content of data.txt? This is on the same folder. It is very strange for me Confused

I see also that Chrome has much precisely error description than Firefox.


RE: Getting data from .lp script - Erwin van der Zwart - 22.06.2017

Hi,

Local files are not supported for protocol schemes, you need to run them from a webserver, you need to use something like a WAMP server for this.

BR,

Erwin


RE: Getting data from .lp script - buuuudzik - 22.06.2017

Thanks ErwinWink