473,806 Members | 2,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Subsequent Calls In a Ajax

4 New Member
Hi to all

Here i have a problem,

I have a search form in that one which is for searching the usernames in the database
It works fine when i search the UserNames at first time.

When i have changed the UserName in the text box and submits then it is not making a request and fetch the details from the server.
After first request if i have checked with alerts the http_request.re adyStatus=1

For this i am pulling out my hair and googling it and many things i am doing it
can any body help on this please

here i am providing the code for the ajax
Expand|Select|Wrap|Line Numbers
  1.  
  2.  function makePOSTRequest(url, divTag, params) {
  3.       var http_request = false;
  4.  
  5.       if (window.XMLHttpRequest) { // Mozilla, Safari,...
  6.          http_request = new XMLHttpRequest();
  7.          if (http_request.overrideMimeType) {
  8.              // set type accordingly to anticipated content type
  9.             //http_request.overrideMimeType('text/xml');
  10.             http_request.overrideMimeType('text/html');
  11.          }
  12.       } else if (window.ActiveXObject) { // IE
  13.          try {
  14.             http_request = new ActiveXObject("Msxml2.XMLHTTP");
  15.          } catch (e) {
  16.             try {
  17.                http_request = new ActiveXObject("Microsoft.XMLHTTP");
  18.             } catch (e) {}
  19.          }
  20.       }
  21.        if (!http_request) {
  22.          alert('Cannot create XMLHTTP instance');
  23.          return null;
  24.  
  25.       }
  26.       http_request.open('POST', url, true);
  27.       http_request.onreadystatechange = function(){ var x = alertContents(divTag,http_request)};
  28.  
  29.       http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  30.       http_request.setRequestHeader("Content-length", params.length);
  31.       http_request.setRequestHeader("Connection", "close");
  32.       http_request.setRequestHeader("Cache-Control","no-cache");
  33.       http_request.send(params);
  34.    }
  35.  
  36.    function alertContents(divTag,http_request) {
  37.       alert(http_request.readyState);
  38.       if (http_request.readyState == 4) {
  39.           alert(http_request.status);
  40.          if (http_request.status == 200) {
  41.             //alert(http_request.responseText);
  42.             result = http_request.responseText;
  43.             document.getElementById(divTag).innerHTML = result; 
  44.             http_request = false;
  45.          } else {
  46.             alert('There was a problem with the request.');
  47.             http_request = false;
  48.          }
  49.       }
  50.    }
  51.  
  52.  
  53.    function retrieveSearchResults(url,divTag,params){
  54.       alert(url+"\n"+divTag+"\n"+params);
  55.       makePOSTRequest(url,divTag,params);
  56.    }
  57.  
  58.  
  59.  
and here is the code where i am making the call to ajax
Expand|Select|Wrap|Line Numbers
  1. <form action="javascript:retrieveSearchResults('searchResults.jsp','myspan','UserName='+escape(document.getElementById('UserName').value));" name="myform" id="myform" >
  2.  <table cellspacing="2" cellpadding="1" border="0" width="40%" align="center">
  3. <tr>
  4.     <td>User Name</td>
  5.     <td><input type="text" name="UserName" size="15"></td>
  6.     <td></td>
  7. </tr>
  8.  
  9. <tr>
  10.     <td>User Course</td>
  11.     <td><input type="text" name="UserCourse" size="15"></td>
  12.     <td></td>
  13.     <td><input type="Reset" value="clear" style="width:50px;"></td>
  14.     <td><input type="submit" name="go" value="go" style="width:50px;"></td>
  15. </tr>
  16.  
  17.  
  18. </table>
  19. </form>
  20.  
In this one i will search for the UserName

Thanks In Advance
Hari
Sep 19 '08 #1
1 1227
acoder
16,027 Recognized Expert Moderator MVP
Maybe the result is being cached. Have you tested in all browsers?
Sep 26 '08 #2

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

Similar topics

49
2635
by: Mark Hahn | last post by:
As we are addressing the "warts" in Python to be fixed in Prothon, we have come upon the mutable default parameter problem. For those unfamiliar with the problem, it can be seen in this Prothon code sample where newbies expect the two function calls below to both print : def f( list= ): print list.append!(1) f() # prints
9
2259
by: Sudesh Sawant | last post by:
Hello, We have an application which communicates using remoting. There is a server which is a Windows Service. The server exposes an object which is a singleton. The client is a Web Application which makes calls to the service. We are using tcp channel which is using binaryformatter by default. The problem is that after a certain number of remoting calls the calls dont get through to the server. The client application makes the call and...
42
34252
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox 1.07/Linux, Firefox 1.5/Linux, Firefox 1.5/Windows and Firefox 1.5/Mac, Safari/Mac. It works perfectly on a lot of configurations but, on some PC with Firefox 1.5/Windows (not all), the Javascript code with XmlHttpRequest
102
6828
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem never to send if-modified-since. But the strange thing is that Opera sends if-modified-since but when I reply with "HTTP/1.0 304 Not Modified" it is not refreshing the screen from its cache, it is leaving the screen blank.
1
2610
by: r_o | last post by:
hi all, i have a new problem now i'm quick huh :D well what can i say im still a beginner the thing is im using ajax to replace a drop down list with another inside a div upon a choice made by the user.The problem is with the charset, see in the main page the one that calls the ajax code, data is displayed as it should be, but when the ajax code calls the server side script and replaces the drop down list, foreign characters are replaced...
3
2290
by: samikrc | last post by:
Hello, I have an accordion (using the Rico framework at www.openrico.org) and each tab of the accordion is basically some sort of wizard (having a description and a 'Start' button in each tab). When the Start button is pressed, I get the contents of only that tab updated. I am using the innerHTML property of the div placeholder to update the contents, and the HTML is provided from a perl script on the server side. The page layout looks...
3
3956
by: dhsieh | last post by:
I am trying out nested AJAX calls for the first time, but I seem to have hit a snag. The code snippet is the outer AJAX call and a function, it gathers information about a company. As we get towards the bottom of the onComplete function, there is a call to doGetAddressContacts(), which accepts an address ID. This then returns a list of contacts at that address. What I am trying to do is for each address that it retrieves and outputs, as it...
5
2345
by: Eyeinstyin | last post by:
Basic Problem is Every scroll of scrollbar makes an ajax call.So if user play with scrollbar say 100 times 100 ajax calls go and server starts processing 100 calls.So abort won't help.The last time the scroll bar has stopped scrolling(say for 1000 millisecond),ajax call should go.My function uses object function call.So how can i use setTimeOut() My function looks likes this temp contain xmlHTpp object var temp=new xmlHttpObject(); ...
7
4606
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
我们现在遇到一个问题,通过wcf创建的webservice,选择windows service作为宿主,采用java作为客户端调用成功,但是无法使用asp.net ajax调用。 我们参考了http://msdn.microsoft.com/zh-cn/library/bb410780.aspx的资料,并且下载了相应的sample code,但是发现这些sample基本上都需要在iis上部署一个svc文件,但是根据当前业务需求,我们无法部署iis服务器。...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10618
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.