简体   繁体   中英

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?

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).

它与每个javascript(ajax)函数对于电话间隙一样,在您的情况下,它只是一个无效的证书问题,根据https服务器是关注。

If the original loaded page is not connected via https:// then your Ajax calls will not work over https://.

Also Ajax calls must be on the same domain as the main site, as javascript does not allow cross domain Ajax connections.

Also ensure the server side function requested by the Ajax call is returning something other than null.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM