IE 7 Receiving a Parse Error Calling a Web Service
I'm using 1.4.1 and I have two html files, the first one contains
- $(document).ready(function() {
- $('#recordHit').load("http://localhost/soapcall2.html");
- });
the second file, soapcall2.html contains just the following (no <html/>,<head/> or <body/> tags)
- <script>
- var ServiceUrl = '/ws/';
- var CreateSession = ServiceUrl + 'general.asmx?op=CreateUserSession';
- var AddRecord = ServiceUrl + 'record.asmx?op=CreateRecord';
- var TerminateSession = ServiceUrl + 'general.asmx?op=TerminateSession';
- var WebAPIUser = 'webapi';
- var WebAPIPass = 'password';
- var Instance = '50000';
- var sessiontoken = null;
- function CreateUserSession(userName, pin, passwd)
- {
- var soapMessage = '<?xml version="1.0" encoding="utf-8"?>\n<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">\n<soap:Body>\n<CreateUserSession xmlns="http://local/webservices/">\n<userName>' + userName + '</userName>\n<pin>' + pin + '</pin>\n<password>' + passwd + '</password>\n</CreateUserSession>\n</soap:Body>\n</soap:Envelope>';
$.ajax({
- url: CreateSession,
- type: "POST",
- async: false,
- dataType: "xml",
- data: soapMessage,
- contentType: "text/xml",
- error: function(XMLHttpRequest, textStatus, errorThrown){
- alert("XMLHttpRequest\n"+XMLHttpRequest.responseText+"\n\ntextStatus\n"+textStatus+"\n\nerrorThrown\n"+errorThrown);
- },
- complete: function(xmlHttpRequest, status){
- if (status == "success")
- {
- $(xmlHttpRequest.responseXML)
- .find('CreateUserSessionResponse')
- .each(function()
- {
- sessiontoken = $(this).find('CreateUserSessionResult').text();
- })
- }
- }
- });
- return false;
- }
- CreateUserSession(WebAPIUser, Instance, WebAPIPass);
- </script>
In IE 7/8 the error: event is triggered with the correct XML (XMLHttpRequest.responseText) but the textStatus reports parserror and the errorThrown returns [object error]. In firefox it runs without any problems and properly sets the sessiontoken variable.
What could be the issue?