Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get around a 'NS_ERROR_ILLEGAL_VALUE' error using Ajax?
    primarykey
    data
    text
    <p>Im just writing a small Ajax framework for re-usability in small projects and i've hit a problem. Basically i get a '<code>NS_ERROR_ILLEGAL_VALUE</code>' error while sending the request and i've no idea what is happening.</p> <p>The HTML Page (trimmed but shows the error)</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;Ajax Test&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;script type="text/javascript"&gt; var COMPLETE = 4; var OK = 200; function GetXMLHttpRequestObject() { var XMLHttpRequestObject = false; if(window.XMLHttpRequest) { if(typeof XMLHttpRequest != 'undefined') { try { XMLHttpRequestObject = new XMLHttpRequest(); } catch (e) { XMLHttpRequestObject = false; } } } else if (window.ActiveXObject) { try { XMLHttpRequestObject = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { try { XMLHttpRequestObject = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) { XMLHttpRequestObject = false; } } } else { XMLHttpRequestObject = false; } return XMLHttpRequestObject; } //The Main Ajax Object function AjaxRequest(p_RequestMethod, p_DestinationURL) { this.XMLHttpRequestObject = GetXMLHttpRequestObject(); this.RequestedMethod = p_RequestMethod; this.DestinationURL = p_DestinationURL; this.XMLHttpRequestObject.open(this.RequestMethod, this.DestinationURL); this.OnStateChange = function(Callback) { this.XMLHttpRequestObject.onreadystatechange = Callback; } this.Send = function(p_Content) { this.XMLHttpRequestObject.send(p_Content); } this.GetState() { return this.XMLHttpRequestObject.readyState; } this.GetResponseText = function() { return this.XMLHttpRequestObject.responseText; } this.GetResponseStatus = function() { return this.XMLHttpRequestObject.status; } this.GetResponseStatusText = function() { return this.XMLHttpRequestObject.statusText; } } var Request; function GetData() { Request = new AjaxRequest('POST', 'http://www.kalekold.net/ajax/Ajax.php'); Request.OnStateChange = StateChange; Request.Send(); } function StateChange() { window.alert("State: " + Request.GetState()); window.alert("Response: " + Request.GetResponseStatus()); window.alert("Response Text: " + Request.GetResponseStatusText()); if(Request.GetState() == COMPLETE &amp;&amp; Request.GetResponseStatus() == OK) { Result = Request.GetResponseText(); window.alert(Result); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;textarea name="TextArea" rows="10" cols="80"&gt;&lt;/textarea&gt;&lt;br /&gt; &lt;input type="button" value="Load" onClick="GetData();"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The PHP File:</p> <pre><code>&lt;?php $XML = &lt;&lt;&lt; PROLOG &lt;?xml version="1.0" encoding="iso-8859-1"?&gt; PROLOG; $XML .= "&lt;results&gt;"; $XML .= "&lt;result&gt;"; $XML .= "&lt;FirstName&gt;Gary&lt;/FirstName&gt;"; $XML .= "&lt;SecondName&gt;Willoughby&lt;/SecondName&gt;"; $XML .= "&lt;Age&gt;35&lt;/Age&gt;"; $XML .= "&lt;/result&gt;"; $XML .= "&lt;result&gt;"; $XML .= "&lt;FirstName&gt;Sara&lt;/FirstName&gt;"; $XML .= "&lt;SecondName&gt;Gostick&lt;/SecondName&gt;"; $XML .= "&lt;Age&gt;35&lt;/Age&gt;"; $XML .= "&lt;/result&gt;"; $XML .= "&lt;/results&gt;"; header("Content-Type: text/xml"); echo $XML; ?&gt; </code></pre> <p>The full error:</p> <pre><code>uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://www.kalekold.net/ajax/ :: AjaxRequest :: line 63" data: no] Line 0 </code></pre> <p>I just can't see where it's going wrong, any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload