我见过一些人有像我这样的问题,但大多数修复似乎并不相关。我有以下 jquery,它采用提交的表单,使用 SHA256 传递密码,将表单序列化为 JSON 对象,然后使用 json stringify 将 json 格式化为纯文本格式以传递给 ASPX 服务。服务返回 XML。这适用于 Firefox、Chrome、Safari、Opera、iOS Safari、Blackberry 和默认的 Android 浏览器。在 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>
我真的很感激任何和所有的帮助。Firebug 没有抛出任何错误,我真的很困惑它是如何在除 IE 之外的所有东西上工作的。我在 CSS 中习惯了这一点,但在 JS 中不习惯!
编辑 - 我已将错误更改为显示 errorThrown,其中显示“无传输”。