Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an https request in javascript?

I am doing phonegap app, I want to access web service from server, in coding javascript get,post or ajax methods working fine for http url request but it cant work for https url request. Please help me, how to called SOAP or secure web service to parse JSON in phonegap through javascript?

like image 739
Mayur Birari Avatar asked May 18 '26 08:05

Mayur Birari


1 Answers

HTTPS is not another protocol, it is merely HTTP over an SSL/TLS- encrypted connection. Since that encryption works transparent to the user agent, to perform a HTTPS AJAX call on your own domain name, your site must be using HTTPS, otherwise you are not able to selectively choose HTTPS on a page you want to perform an AJAX call on that isn't already using HTTPS.

So basically you can't call 'https://yourdomain.com/fetch' if the page you're calling the AJAX request from isn't using HTTPS.

If you want to perform an AJAX call to a HTTPS domain hosted somewhere else other than your domain, it is somewhat possible to do so (but only in Firefox 3.5+, Safari, Chrome and I think Opera), there is some interesting information about how to make cross-domain AJAX requests possible here: http://metajack.im/2010/01/19/crossdomain-ajax-for-xmpp-http-binding-made-easy/ - this method is not supported in IE (no surprise there).

like image 141
Dwayne Charrington Avatar answered May 19 '26 20:05

Dwayne Charrington



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!