Page 1 of 2

Execute http get from javascript?

Posted: Wed Mar 11, 2015 6:51 pm
by jmd2004

I'm trying to create a button that will execute an http get command. For example

https://home-server.com/contact//scri...

I can get this to work when I use an html object and set the form action correctly. The issue I have is that my app will navigate to my external server after the users submits the form.

Any chance I can achieve the same functionality without an HTML form? In a perfect world i would love to use the native input objects for form data and then have the user click a button that would execute the http post in the back ground.

Any help would be greatly appreciated!!!

Thanks!
James


Execute http get from javascript?

Posted: Thu Mar 12, 2015 4:51 pm
by Egor Kotov6832188

Hello James,
Appery.io platform provides elegant way to create any type of requests
Please use this doc to create a REST without web form
http://devcenter.appery.io/documentat...
There is a Test tab for every service, which you can use to see results of your request


Execute http get from javascript?

Posted: Sun Mar 15, 2015 12:06 am
by jmd2004

I can't create a REST service on the destination server, all i can do is send an http get/post action; The snippet bellow is working fine statically.

$.get( "https://home-server.com/contact//scri..."} );

I just need to figure out a way to add variables from my applicaiton into the javascript. Specifically how would I read/reference a storage variable and insert it into the URL.

Thanks again for your help! I'm almost done with my proof of concept for work and your app is awesome!


Execute http get from javascript?

Posted: Sun Mar 15, 2015 9:08 pm
by jmd2004

I can't build a REST webservice.


Execute http get from javascript?

Posted: Mon Mar 16, 2015 2:45 am
by Yurii Orishchuk

Hello,

You can use jQuery ajax function for this goal.
Details: http://api.jquery.com/jquery.ajax/

But note: this is external service thus you will have cross origin request issues in this case if you test/run it in the browser.

If you use Appery.io services - you can set "Appery.io proxy" and it will fix cross origin problem.

Regards.


Execute http get from javascript?

Posted: Sat Mar 21, 2015 2:08 pm
by jmd2004

@yuri - i don't understand your suggestion. is their not a way to lets say insert a variable into an event javascript.


Execute http get from javascript?

Posted: Tue Mar 24, 2015 7:01 pm
by Egor Kotov6832188

Hello,

a way to add variables from my applicaiton into the javascript

var myLSV1 = localStorage.getItem("MYLSV1");
var myLSV2 = localStorage.getItem("MYLSV3");

$.get( "https://home-server.com/contact//scri...", { var1: myLSV1, var2: myLSV2} );


Execute http get from javascript?

Posted: Fri Mar 27, 2015 6:11 pm
by jmd2004

Egor,

Thanks for your response!


Execute http get from javascript?

Posted: Mon Mar 30, 2015 4:41 pm
by jmd2004

Hi Egor,

Your suggestion worked perfectly! I'm now trying to also add a variable into the url from a "select" menu.

The user will select a duration measured in minutes and click submit.

var myLSV1 = localStorage.getItem("MYLSV1");
var myLSV2 = localStorage.getItem("MYLSV3");
var myDuration =

$.get( "https://home-server.com/contact//scri...", { var1: myLSV1, var2: myLSV2} );

Do you know how this can be accomplished?

Thanks again for all of your help!
James


Execute http get from javascript?

Posted: Mon Mar 30, 2015 7:38 pm
by jmd2004

This worked for me!