I'm writing a simple example to see how an iphone reacts to Http and Https... but weirdly, I can't get it working as the ajax call doesn't do anything. It works well on everyother browser, including safari, but not on Ipod Touch.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript">
function goHttps() {
var curUrl = window.location.toString();
var string = curUrl.substring(4);
var newUrl = "https" + string;
window.location = newUrl;
}
function test1(){
var curUrl = window.location.toString();
var string = curUrl.substring(5);
var newUrl = "http" + string;
$("#hiddenForm").attr("action", newUrl);
$("#hiddenForm").submit();
}
function test2(){
var curUrl = window.location.toString();
var string = curUrl.substring(5);
var newUrl = "https" + string;
$("#hiddenForm").attr("action", newUrl);
$("#hiddenForm").submit();
}
function test3(){
var curUrl = window.location.toString();
var string = curUrl.substring(5);
var newUrl = "http" + string;
$.get(newUrl, function(data) {
$("#NextPar").append("<span style = 'color: #ff0000; background: #ffff00; font-size: 2em;'>Request Done</span>");
});
}
jQuery(window)
.bind(
"load",
function() {
//Test https status;
var curUrl = window.location.toString();
if (curUrl.indexOf("https://") > -1) {
$("#HttpStatusPar")
.html(
"Ok you are in HTTPS mode. The connection is encrypted.");
$("#NextPar")
.html(
"Let's have a test now. First a HTTP request to THIS site. Click here <button onclick ='test1();'>Local HTTP request</button>, this should rise a popup (in firefox does) as you are sending data on a non encrypted connection");
$("#NextPar").append("<p>Now let's try with a HTTPS request... this <b>shouldn't</b> rise up any kind of problem as you are still in an encrypted environment <button onclick='test2();'>HTTPS req</button></p>");
$("#NextPar").append("<p>Now let's try with a HTTP request again, using Ajax this time... this <b>could</b> potentially rise up a problem as you are requesting data like before, on an unencrypted channel, while you are on a supposedly secure page. anyway on most browsers it doesn't. <button onclick='test3();'>Ajax HTTP req</button></p>");
} else {
$("#HttpStatusPar")
.html(
"You are not in HTTPS mode. Click <a onclick = 'goHttps();'>ME</a>");
}
});
</script>
</head>
<body>
<p>Hello, just testing a cross domain HTTPS request... just to see
if it is feasible using jQuery</p>
<br>
<p id="HttpStatusPar"></p>
<p id="NextPar"></p>
<div style = "visibility: hidden;">
<form method="get" id = "hiddenForm">
<input type="hidden" name = "test1"/>
</form>
</div>
</body>
</html>
Ideas?