我見過幾個人,像我這樣的問題,但大多數修復似乎並不相關。我有以下jquery採用提交的表單,使用SHA256加密傳遞,將表單序列化爲JSON對象,然後使用json stringify將json格式化爲純文本格式以傳遞給ASPX服務。該服務返回XML。這適用於Firefox,Chrome,Safari,Opera,iOS Safari,Blackberry和默認的Android瀏覽器。在IE上它總是調用錯誤。有沒有人有任何想法嗎?jQuery AJAX POST可以在除IE以外的所有瀏覽器中工作
$(function() {
$('form').submit(function() {
$('#password').val($.sha256($('#password')));
var jsonTest = JSON.stringify($('form').serializeObject());
$('#result').text(jsonTest);
$.ajaxSetup({cache: "false"});
$.ajax({
type: "POST",
url: "http://mydomain.com/JSONService.asmx/WebRequest",
data: "request=" + jsonTest,
contentType: "application/x-www-form-urlencoded; charset=utf-8",
crossDomain: true,
dataType: "xml",
success: function(xml){
var myVals = $(xml).find('string').text();
$('#result').text(myVals);
alert(myVals);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Error: " + errorThrown);
}
});
return false;
我的(相關)HTML:
<!doctype html>
<!-- Conditional comment for mobile ie7 blogs.msdn.com/b/iemobile/ -->
<!--[if IEMobile 7 ]> <html class="no-js iem7" lang="en"> <![endif]-->
<!--[if (gt IEMobile 7)|!(IEMobile)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Test Form</title>
<meta name="description" content="">
<!-- Mobile viewport optimization h5bp.com/ad -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width">
<!-- Mobile IE allows us to activate ClearType technology for smoothing fonts for easy reading -->
<meta http-equiv="cleartype" content="on">
<!-- more tags for your 'head' to consider h5bp.com/d/head-Tips -->
<!-- Main Stylesheet -->
<link rel="stylesheet" href="css/style.css">
<!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects -->
<script src="js/libs/modernizr-2.0.6.min.js"></script>
</head>
<body>
<div id="container">
<div id="main" role="main">
<div id="logBox">
<img alt="Logo" src="img/logo.png" style="margin-left: 5px;" />
<div id="blackHead">Please Sign-In To Continue</div>
<form name="login" method="post" action="#">
<label for="sessionemail">Email</label><br />
<input autofocus="autofocus" autocapitalize="off" maxlength="150" id="sessionemail" name="sessionemail" title="Your email" type="text" value="" class="inputText" /><br />
<br />
<label for="password">Password</label><br />
<input type="password" name="password" id="password" title="Password" value="" class="inputText" /><br />
<br />
<input type="hidden" name="sessionid" id="sessionid" value="<?php echo $sessionNumber ?>" />
<input type="hidden" name="subtocall" id="subtocall" value="g2.web.login.sub" />
<input type="submit" value="Sign-In" name="submit" class="submitBox" />
</form>
<div id="greyFoot">Forgot your password? <a href="#">Click here now!</a><br />
<pre id="result">
</pre>
</div><!-- end #greyFoot -->
</div><!-- end #logBox -->
</div><!--end #main -->
</div> <!--! end of #container -->
</body>
</html>
我真的很感激任何和所有幫助。螢火蟲不會拋出任何錯誤,我真的很難爲它如何在IE瀏覽器上運行。我習慣了CSS而不是JS!
編輯 - 我改變了錯誤,顯示errorThrown,它表示「沒有運輸」。
你確定你使用的IE版本支持'.stringify'嗎? – 2012-07-26 14:33:22
IE吮吸http://www.iesucks.info/ – Don 2012-07-26 14:33:35
你可以提醒一些有用的東西,而不是'alert(「Error Occured!」);' – Shikiryu 2012-07-26 14:33:39