Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I am getting unspecified error

 
Veshnu Ramakrishnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you setting after the open() method has been declared?

Eric
 
Veshnu Ramakrishnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't you open the request before setting the headers ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic