我的应用服务器上有一个.Net webservice,它返回格式化为JSONP的数据。我在该服务器上有一个HTML测试客户端,使用IE,Firefox和&铬。如果我将相同的HTML复制到我的工作站或部署到我的网络服务器,它适用于Firefox& Chrome但在IE中我遇到两个javascript错误。
消息:对象不支持此属性或方法
行:1
字符:1
代码:0
URI:http:// mydomain / WebServices / LyrisProxy / Services / Lyris / JSONP / Lyris.asmx / AddUser?lyrisInstance =“1”& email =“myemail@gmail.com”& fullName =“My Name”& lyrisList =“listname”& format = json& callback = jsonp1274109819864& ; _ = 1274109829665
消息:未找到成员。
行:59
字符:209
代码:0
URI:http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
我有点不知道如何解决这个问题。
这是我的javascript。它实际上不是导致错误的JSONP,而是对jqModal ev.preventDefault(); 的调用。我现在正试图通过这个来看看为什么它会在IE上用外部引用进行轰炸。
<script type="text/javascript">
$(document).ready(function() {
$("#createUser").live("click", function(ev) {
var invalidEmailAddressMessage = "That isn't a valid email address.";
var userSuccessfullyAddedMessage = "Congrats! You've been added to the iStage mailing list.";
var userAlreadyExistsMessage = "Looks like you're already on our mailing list!";
var genericErrorMessage = "Something fishy happened. I don’t know what to tell you.";
// check for a valid email address
var regEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(regEmail.test($("#email").val()) == false) {
// invalid email address. Show error and let user retry.
ev.preventDefault();
$('#lyrisReturnStatus').jqmShow().oneTime(3500, "soon", function() {
$('#lyrisReturnStatus').jqmHide();
});
$("#output").html(invalidEmailAddressMessage);
$("#email").select();
return;
}
// Call the proxy to add the user
var service = new WS("http://apps.ce.org/WebServices/LyrisProxy/Services/Lyris/JSONP/Lyris.asmx", WSDataType.jsonp);
service.call("AddUser", { lyrisInstance:$("#lyrisInstance").val(), email:$("#email").val(), fullName:$("#fullName").val(), lyrisList:$("#lyrisList").val() }, function(AddUser) {
var lyrisReturn = JSON.parse(AddUser);
var goBack;
var timeout;
// See if the JSON returned is an error message and handle.
if(typeof(lyrisReturn.ErrorMessage) !== 'undefined' && lyrisReturn.ErrorMessage != null) {
var pos=lyrisReturn.ErrorMessage.indexOf("member already exists");
if (pos>=0)
{
// Member already exists.
$("#output").html(userAlreadyExistsMessage);
goBack = true;
} else {
// Generic error.
$("#output").html(genericErrorMessage);
goBack = false;
}
timeout = 3500;
}
// See if the JSON returned the expected MemberID
if(typeof(lyrisReturn.MemberID) !== 'undefined' && lyrisReturn.MemberID != null) {
$("#output").html(userSuccessfullyAddedMessage);
goBack = true;
timeout = 2000;
}
//Show the modal display with the appropriate messaging and redirect.
ev.preventDefault();
$('#lyrisReturnStatus').jqmShow().oneTime(timeout, "soon", function() {
$('#lyrisReturnStatus').jqmHide();
if(goBack) {
history.go(-1);
}
});
});
});
$('#lyrisReturnStatus').
jqm({ overlay: 50, modal: true, trigger: false });
});
</script>