By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Ajax/.Net 1.1 readyState problem

P: 1
The code below is working to a point. At the http_request.readyState statement I get a state of one. How do I complete the process so I can get a state of four and/or another means of getting a value back to the page?


server-side C#
private void Page_Load(object sender, System.EventArgs e){
string[] token=new StreamReader(Request.InputStream).ReadToEnd().Spli t('^');
ajax_post(token);
}

public void ajax_post(string[] token){
string page=token[1];
XmlDocument doc=new XmlDocument();
doc.Load(@"c:\Inetpub\wwwroot\ajax_post\"+token[0]);
XmlNode answer_node=doc.DocumentElement.SelectSingleNode(" page[@id="+page+"]/answers");
answer_node.InnerText=token[3];
doc.Save(@"c:\Inetpub\wwwroot\ajax_post\"+token[0]);
}


client-side javascript
function create_ajax_object(){
if(window.XMLHttpRequest){
http_request=new XMLHttpRequest();
}else if(window.ActiveXObject){
try{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
if(!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
}

function save_page(type){
create_ajax_object();
http_request.open('POST','http://localhost/ajax_post/ajax_post.aspx',true);
http_request.send(xml_file+"^"+ current_page +"^next^1~2~3~4");
alert(http_request.readyState);
}

xml file
<?xml version="1.0"?>
<pages>
<page id="1">
<answers></answers>
</page>
<page id="2">
<answers></answers>
</page>
<page id="3">
<answers></answers>
</page>
<page id="4">
<answers></answers>
</page>
<page id="5">
<answers></answers>
</page>
<page id="6">
<answers></answers>
</page>
</pages>
Apr 25 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.