Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-16-2010, 11:42 AM   PM User | #1
mor_mah
New to the CF scene

 
Join Date: Jun 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
mor_mah is an unknown quantity at this point
Ajax doesn't work sometimes

I use the following code :

function createXHR() {
var request = false;
try {
request = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (err2) {
try {
request = new ActiveXObject('Microsoft.XMLHTTP');
}
catch (err3) {
try {
request = new XMLHttpRequest();
}
catch (err1) {
request = false;
}
}
}
return request;
}

function sendRequest() {
var validate=document.getElementById('validate').value;
querystring = 'validate=' + validate;
xhr.open('POST', 'validate.php', true);
xhr.onreadystatechange = sayHello;
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(querystring);
}


function sayHello() {
if (xhr.readyState == 4) {
//return answer
}
}

xhr = createXHR();


this code sometimes works and sometimes doesn't work.
how we can sure that above code works?
mor_mah is offline   Reply With Quote
Reply

Bookmarks

Tags
ajax, load

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:48 PM.


Advertisement
Log in to turn off these ads.