File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes I am getting unspecified error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "I am getting unspecified error" Watch "I am getting unspecified error" New topic
Author

I am getting unspecified error

Veshnu Ramakrishnan
Ranch Hand

Joined: Sep 27, 2005
Posts: 44
When i try to set a header like this
req.setRequestHeader("Content-Type", "text/xml");

i am getting an unspecified javascript error at this point. i couldn't set anything to my header. can anyone help me out in this.


Veshnu<br />SCBCD<br />SCWCD<br />SCJP
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Are you setting after the open() method has been declared?

Eric
Veshnu Ramakrishnan
Ranch Hand

Joined: Sep 27, 2005
Posts: 44
no i am setting it before the open method
var idField = document.getElementById("searchQuery").value;
var action = document.getElementById("action").value
var url = "http://localhost:7001/cplus/go";
if (window.XMLHttpRequest) {
alert("xml http");
try{
req = new XMLHttpRequest();
}catch(e){
alert("No http xml");}
} else if (window.ActiveXObject) {
alert("ActiveX");
try{
req = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){alert("No Active X");}
}
req.setRequestHeader("ACTION", action);
req.setRequestHeader("Content-Type", "text/xml");
req.open("POST", url, true);
req.onreadystatechange = callback;
req.send(idField);

This is my code snippet
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Shouldn't you open the request before setting the headers ?


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I am getting unspecified error