jmd2004
Posts: 1
Joined: Wed Jan 28, 2015 7:06 pm

Execute http get from javascript?

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

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

Execute http get from javascript?

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

jmd2004
Posts: 1
Joined: Wed Jan 28, 2015 7:06 pm

Execute http get from javascript?

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!

jmd2004
Posts: 1
Joined: Wed Jan 28, 2015 7:06 pm

Execute http get from javascript?

I can't build a REST webservice.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Execute http get from javascript?

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.

jmd2004
Posts: 1
Joined: Wed Jan 28, 2015 7:06 pm

Execute http get from javascript?

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

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

Execute http get from javascript?

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

jmd2004
Posts: 1
Joined: Wed Jan 28, 2015 7:06 pm

Execute http get from javascript?

Egor,

Thanks for your response!

jmd2004
Posts: 1
Joined: Wed Jan 28, 2015 7:06 pm

Execute http get from javascript?

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

jmd2004
Posts: 1
Joined: Wed Jan 28, 2015 7:06 pm

Execute http get from javascript?

This worked for me!

Return to “Issues”