Hi Friends,
I have a web application through which, the ajax is used to post the data onto the server and return the results. When i alert the xmlhttp.readystate sometimes it takes long time, that the process looks like freezing and sometimes its done very quickly as it is designed to.
I checked by alerting xmlhttp.readystate.
sometimes i get response 1,2 ,3 4 as the alert box quickly.
and sometimes i just get 1 and then nothing happens.
Has any one experienced the same.
Regards,
Anubhav
10 7093
maybe problem with your PHP file. Try to send the same variables to the file through a manual call (enter it in your browser address bar), it maybe that this file never gets back.
Only thing I can think of that causes this.
Dan
Just try to get the response from a dummy PHP file...
If the response time is same for every call.. then as dlite922 told its a problem with your PHP... Prpbably you need to fix some issues..
Regards
Dheeraj Joshi
I did not faced such problems.
I checked that , but if i send the variables directly to the php file as the action in the form tag, it goes out fine. I am using IE 7.0 and sometimes it works fine and sometimes does not work.
Check it in FF(Fire Fox)... I got some problem when i used AJAX call in IE(Though not similar)...
Regards
Dheeraj Joshi
Hi Dheeraj,, even firefox and ie shows the same response. and there is a javascript code written that the web application cannot be used on a firefox. can you think of something else.
Do think that multiple requests are being fired off?
If so, that may part of the bottleneck.
If I remember correctly, IE will open only 2 connections at once.
You might also want to add a timeout in your Ajax callback function so the application is more responsive. http://ajax.sys-con.com/node/352578
Post your httpRequest and callback function.
gits 5,390
Expert Mod 4TB
that seems more to be a problem with the JavaScript-code then with the php-code. could you post the JavaScript-code that is relevant for the ajax-call?
kind regards
Ok.... I dont know any other solution.
Just post the Java script like GITS told... It may be the culprit....
Regards
Dheeraj Joshi
@dgreenhouse
Thank you for your reply.
I dont know to check if the multiple requests are being fired off.can you pls provide detail on it.
First i was using the following codes:-
The function is called on submit of a button. - function submitform()
-
{
-
result=0;
-
//gettting the form values;
-
var requestid=document.getElementById("requestid").value;
-
var sdenggname=document.getElementById("sdenggname").value;
-
var sla=document.getElementById("sla").value;
-
var helpdesk_comments=document.getElementById("helpdesk_comments").value;
-
var calltype=document.getElementById("calltype").value;
-
//validation part
-
if(sdenggname=="--"||sla=="--"||helpdesk_comments==""||calltype=="--")
-
{
-
alert("Please make sure that you have filled in all the fields");
-
return false;
-
}
-
//validateion part end
-
var domain=document.domain;
-
-
var url = "http://"+domain+"/crfportal/assignhelpdeskcalls_submit.php"; //url
-
-
var params = "requestid="+requestid+"&sdenggname="+sdenggname+"&sla="+sla+"&helpdesk_comments="+helpdesk_comments+"&calltype="+calltype; //generating parameters
-
-
//displaying the user with a statment while the request is being sent.
-
document.getElementById("d1").innerHTML="<table><tr><td>Please wait while the call is getting assigned</Td></tr></table>"
-
var xmlhttp=false;
-
//alert(params);
-
/*@cc_on @*/
-
/*@if (@_jscript_version >= 5)
-
// JScript gives us Conditional compilation, we can cope with old IE versions.
-
// and security blocked creation of the objects.
-
try {
-
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
-
} catch (e) {
-
try {
-
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
-
} catch (E) {
-
xmlhttp = false;
-
}
-
}
-
@end @*/
-
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
-
try {
-
xmlhttp = new XMLHttpRequest();
-
} catch (e) {
-
xmlhttp=false;
-
}
-
}
-
if (!xmlhttp && window.createRequest) {
-
try {
-
xmlhttp = window.createRequest();
-
} catch (e) {
-
xmlhttp=false;
-
}
-
}
-
//alert("xmlhttp"+xmlhttp);
-
try{xmlhttp.open("POST", url, true);}
-
catch(e)
-
{
-
alert("some error");
-
}
-
-
//Send the proper header information along with the request
-
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
-
xmlhttp.setRequestHeader("Content-length", params.length);
-
xmlhttp.setRequestHeader("Connection", "close");
-
-
xmlhttp.onreadystatechange = function() {//Call a function when the state changes.
-
-
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
-
-
result=xmlhttp.responseText;
-
if(result!=0)
-
{
-
window.location="assignsdcalls.php?refresh=1";
-
}
-
}
-
}
-
xmlhttp.send(params);
-
}
Then i changed the above code to the following: - function submitform()
-
{
-
result=0;
-
//gettting the form values;
-
var requestid=document.getElementById("requestid").value;
-
var sdenggname=document.getElementById("sdenggname").value;
-
var sla=document.getElementById("sla").value;
-
var helpdesk_comments=document.getElementById("helpdesk_comments").value;
-
var calltype=document.getElementById("calltype").value;
-
var status=document.getElementById("reqstatus").value;
-
var sdenggcomment=document.getElementById("sdenngcomments").value;
-
//document.form1.submit();
-
//validation part
-
if((status=='Closed'||status=='closed')&& sdenggcomment=="")
-
{
-
alert("The call under closed status need to have comment")
-
return false;
-
}
-
if(sdenggname=="--"||sla=="--"||helpdesk_comments==""||calltype=="--")
-
{
-
alert("Please make sure that you have filled in all the fields");
-
return false;
-
}
-
//validateion part end
-
//setTimeout("",1250);
-
document.getElementById("assigncall").disabled=true;
-
var domain=document.domain;
-
-
var url = "http://"+domain+"/crfportal/assignhelpdeskcalls_submit.php"; //url
-
//var url1 = "http://172.16.140.15/crfportal/assignhelpdeskcalls_submit.php"; //url to be used when the 172.16.140.15 is there.
-
var params = "requestid="+requestid+"&sdenggname="+sdenggname+"&sla="+sla+"&helpdesk_comments="+helpdesk_comments+"&calltype="+calltype+"&status="+status+"&sdenggcomment="+sdenggcomment+ "&rand=" + (new Date()); //generating parameters
-
document.getElementById("d1").innerHTML="<table><tr><td>Please wait while the call is getting assigned</Td></tr></table>"
-
var xmlhttp=false;
-
xmlhttp=new ajaxRequest();
-
try{xmlhttp.open("POST", url, true);}
-
catch(e)
-
{
-
try{xmlhttp.open("POST", url1, true);}
-
catch (e)
-
{
-
alert("some error");}
-
}
-
-
//Send the proper header information along with the request
-
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
-
//xmlhttp.setRequestHeader("Content-length", params.length);
-
//xmlhttp.setRequestHeader("Connection", "close");
-
-
xmlhttp.onreadystatechange = function() {//Call a function when the state changes.
-
//alert(xmlhttp.readyState);
-
-
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
-
result=xmlhttp.responseText;
-
if(result!=0)
-
{
-
//document.getElementById("d1").innerHTML="<table><tr><td>"+result+"</Td><td><a href='assignsdcalls.php'>Assign another calls</a></td></tr></table>";
-
//document.getElementById("assigncall").disabled=true;
-
window.location="assignsdcalls.php?refresh=1";
-
}
-
}
-
}
-
xmlhttp.send(params);
-
-
}
The function ajaxrequest is defined as follows:- - function ajaxRequest(){
-
var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
-
if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
-
for (var i=0; i<activexmodes.length; i++){
-
try{
-
return new ActiveXObject(activexmodes[i])
-
}
-
catch(e){
-
//suppress error
-
}
-
}
-
}
-
else if (window.XMLHttpRequest) // if Mozilla, Safari etc
-
return new XMLHttpRequest()
-
else
-
return false
-
}
when i give alert on xmlhttp.readystate sometimes i get alert as 1234 very quickly and sometimes it just stops after 1.
Also after going through my code, if you see any thing which is not a good programming practice. please let me know.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Trip |
last post by:
Please if someone can help me !!!
I need client and server code(principle based on AJAX) for next problem:
i have 3 <select> tags on html...
|
by: bobzimuta |
last post by:
I'm creating a simple AJAX library. It's an object that will return an
array containing the response text or xml. I'm trying to find a way to...
|
by: petermichaux |
last post by:
Hi,
Is it possible for an AJAX request to be left open for multiple
responses? This could avoid repetitive polling of the server.
Thanks,...
|
by: Tony |
last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET
distribution - I'm pretty concerned about this. Does anyone know if this
is...
|
by: evgenyg |
last post by:
Hello !
We have the following situation - when Ajax request is sent what's
being returned by the server is usually an XML (which is used for DOM...
|
by: Arjen |
last post by:
Hi,
I want to reload 2 divs at one click. Ive tried:
<a href = "javascript:void(0);"...
|
by: simon |
last post by:
hello,
I have a server set up on my local (home) network and can not get an
ajax application to run on the box. it works fine on our...
|
by: zalek |
last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET",
url, false).
I noticed that in FireFox handler doesn't starts. It starts when...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
| |