Use Ajax to submit a HTTPS request

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muiz123
    New Member
    • Jun 2010
    • 8

    #1

    Use Ajax to submit a HTTPS request

    Can we use AJAX to submit a https request in a http page?
    E.g.
    1. Open a page: http://localhost/test.html.
    test.html code:
    Code:
    <html>
    	<head>
    		<script src="script/sys.js" language="JavaScript" type="text/javascript"></script>
    		<script src="script/prototype.js" language="JavaScript" type="text/javascript"></script>
    	</head>
    	<body>
    		<script type="text/javascript">
    			function test() {
    				//var url = "http://localhost/ajax?xxxx";
    				var url = "https://localhost/ajax?xxxx";
    				new Ajax.Request(url, {method: "get",
    	    			onComplete: function(transport) {
    						alert(transport.status + ": " + transport.responseText);
    	    		 	}
    				 });	
    			}
    			test();
    		</script>
    		<form action="https://localhost/ajax?xxxx" name="xx">
    			<input type="submit" value="submit">
    		</form>
    	</body>
    </html>
    2. Then run test script to submit a https request
    the response status is 0. and the response test = ""

    How can we add the SSL exception from a ajax response?
  • Canabeez
    New Member
    • Jul 2009
    • 126

    #2
    You can surely do that with JSON, I believe that changing the protocol would be handled as a cross-domain request which is not allowed in AJAX.

    Comment

    • muiz123
      New Member
      • Jun 2010
      • 8

      #3
      Thanks Canabeez. I will study JSON and try it.

      I download JSONRequest.js, but for JSON.js, I cannot find it. Any ideas?

      BTY, i want to use SSL to validate username and password.

      Comment

      Working...