Calling ajax webservice from OnComplete of an ajax webservice call not firing OnComplete 2nd time
I have an ajaxified .NET webservice that I call from javascript(mootools) on my ASP.NET content page with a Masterpage firstly to check if the user has associated journalists, secondly to delete the user if no journalists are associated.
Both calls to the webservice work, but the onComplete for the second does not in IE8. Using FF 3.5.3 I get a "deleteUserInt is not defined" error in firebug.
I have read around that this can be a sytax error, but cannot seem to see it.
Please help.
var userId;
var siteName;
var siteFolder;
function userInternalHasUserExternals() {
siteName = document.location.href.split("/")[document.location.href.split("/").length - 1];
siteFolder = document.location.href.replace(siteName, "");
var jsonRequest = new Request.JSON({ url: siteFolder + "Service1.asmx/UserInternalHasUserExternals",
onComplete: onComplete,
onFailure: onError,
urlEncoded: false,
headers: { "Content-type": "application/json" }
});
userId = document.getElementById("<%= HiddenId.ClientID %>").innerText;
jsonRequest.send(JSON.encode({ 'userInternalId': userId }));
}
function onComplete(results) {
var fullname = document.getElementById("<%= fullnameTextBox.ClientID %>").value;
if (results != null && results["d"] != null && results["d"]) {
alert("Du kan ikke slette " + fullname + ". Kontoen har journalister tilknyttet.");
return false;
}
var deleteUser = confirm("Er du sikker på du vil slette " + fullname + "?");
if (deleteUser) {
deleteUserInt();
window.location = window.siteFolder + "CreateUserInternal.aspx?IsDeleted=true";
}
else
window.location = window.siteFolder + "EditUserInternal.aspx?UserInternalId=" + window.userId;
}
function deleteUserInt() {
var request;
request = new Request.JSON({ url: window.siteFolder + "Service1.asmx/DeleteUserInternal",
onComplete: onDeleted,
onFailure: onError,
urlEncoded: false,
headers: { "Content-type": "application/json" }
});
request.send(JSON.encode({ 'userInternalId': window.userId }));
}
function onDeleted(args) {
if (args != null && args["d"] != null && args["d"])
window.locatio开发者_如何学JAVAn = window.siteFolder + "CreateUserInternal.aspx?IsDeleted=true";
else
alert("Der skete en fejl. Kontakt venligst site administrator.");
}
function onError() {
alert("Something bad happened!");
}
This was "solved" after I moved my javascript out in a file and found an error using innerText instead of innerHTML.
The IE8 missing function being called also "fixed" itself after being moved.
Of course I had to pass the ClientIds, which I used in my aspx page as parameters to the new method, but that worked fine for me.
For some reason Firefox jumps the gun when I have 2 a confirm and then an alert.
精彩评论