I have a .Net webservice on my app server that returns data formatted as JSONP. I have an HTML test client on that server which works fine using IE, Firefox, & Chrome. If I copy the same HTML to my workstation or deploy to my webserver it works with Firefox & Chrome but in IE I'm getting two javascript errors.
Message: Object doesn't support this property or method
Line: 1 Char: 1 Code: 0 URI: http://mydomain/WebServices/LyrisProxy/Services/Lyris/JSONP/Lyris.asmx/AddUser?lyrisInstance="1"&email="myemail@gmail.com"&fullName="My Name"&lyrisList="l开发者_如何转开发istname"&format=json&callback=jsonp1274109819864&_=1274109829665Message: Member not found.
Line: 59 Char: 209 Code: 0 URI: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.jsI'm kind of at loss as to what to do to fix this.
Here's my javascript. It's actually not the JSONP causing the error but rather the call to jqModal ev.preventDefault();. I'm trying to go through this now to see why it bombs with an external reference to that on 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>
Use a debugger to find the line with the error.
精彩评论