473,322 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Strange AJAX Issue?

384 256MB
I'm having an issue with my AJAX function, its been working fine then I added another link, and now when i click on an AJAX link on the menu, it tries to load the correct page for a split second and then goes back to the menu page, just can't figure it out!?!It works fine on my local setup but once i moved the new link to the live site its stopped working!???
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2.     var loading_img = '/media/images/layout/loading.gif';
  3.     var loading_msg = ' Loading...';
  4.     var xmlhttp_obj = false;//create the XMLHttpRequest
  5.  
  6.     function ewd_xmlhttp()
  7.     {
  8.         if (window.XMLHttpRequest)
  9.         { // if Mozilla, Safari etc
  10.             xmlhttp_obj = new XMLHttpRequest();
  11.         }
  12.         else if (window.ActiveXObject)
  13.         { // if IE
  14.             try
  15.             {
  16.                 xmlhttp_obj = new ActiveXObject("Msxml2.XMLHTTP");
  17.             }
  18.             catch (e)
  19.             {
  20.                 try
  21.                 {
  22.                     xmlhttp_obj = new ActiveXObject("Microsoft.XMLHTTP");
  23.                 }
  24.                 catch (e)
  25.                 {
  26.  
  27.                 }
  28.             }
  29.         }
  30.         else
  31.         {
  32.             xmlhttp_obj = false;
  33.         }
  34.  
  35.         return xmlhttp_obj;
  36.     }   //get content via GET
  37.  
  38.     function getcontent(url, containerid)
  39.     {
  40.         var xmlhttp_obj = ewd_xmlhttp();
  41.         document.getElementById(containerid).innerHTML = '<img src="' + loading_img + '" />' + loading_msg;
  42.         xmlhttp_obj.onreadystatechange=function()
  43.         {
  44.             loadpage(xmlhttp_obj, containerid);
  45.         }
  46.         xmlhttp_obj.open('GET', url, true);
  47.         xmlhttp_obj.send(null);
  48.     }     
  49.  
  50.     function loadpage(xmlhttp_obj, containerid)
  51.     {
  52.         if ( xmlhttp_obj.readyState == 4 && xmlhttp_obj.status == 200 )
  53.         {
  54.             document.getElementById(containerid).innerHTML = xmlhttp_obj.responseText;
  55.         }
  56.     }
  57. //]]>
  58. </script>
  59.  
May 26 '09 #1
3 1295
ziycon
384 256MB
I've done some investigation into this issue and I've found that the correct page is loaded after the first alert but when i clear the second alert from the screen it goes back to the menu page??
Expand|Select|Wrap|Line Numbers
  1. function getcontent(url, containerid)
  2.      {
  3.          var xmlhttp_obj = ewd_xmlhttp();
  4.          document.getElementById(containerid).innerHTML = '<img src="' + loading_img + '" />' + loading_msg;
  5.          xmlhttp_obj.onreadystatechange=function()
  6.          {
  7.              loadpage(xmlhttp_obj, containerid);
  8.          }
  9.          alert(url);
  10.          xmlhttp_obj.open('GET', url, true);
  11.          xmlhttp_obj.send(null);
  12.          alert(url);
  13.      }    
May 26 '09 #2
ziycon
384 256MB
Fixed it, i hadn't got the 'return false;' at the end of the link.
May 26 '09 #3
gits
5,390 Expert Mod 4TB
glad to hear you got it working and posting the solution here so that other members could find it and the hint where to look into when they encounter similar problems.

thanks and kind regards
May 27 '09 #4

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

Similar topics

4
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 assign the response as a property of the object, but...
16
by: Victor | last post by:
I have a strange problem in my website. I configured my website to run under 2 worker processes. (web garden enabled). and I stored my user information in the current httpcontext(like...
1
by: Victor | last post by:
Hi guys i have a strange problem about my modalpopupextender. In my page, i put a gridview inside a updatepanel with paging enabled. also i put a modalpopupextender in another updatepanel to do...
7
by: =?Utf-8?B?Tmlrb2xheSBFdnNlZXY=?= | last post by:
Hi! I know this topic has been discussed a long way, but I haven't found any apparent solution (maybe I shouldn't be looking for a one :)) I have a very simple application with one page and with...
1
by: Victor | last post by:
Hi guys, I have a very strange problem with scriptmanager here. I want to load a js (which is embed in the project) but everytime i try to load that, it gives me error like Specified argument was...
5
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 developement server and also works fine locally. I...
6
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered...
11
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit (using .net version 3.5) is closed before the Ajax enable controls complete loading, then IE locks up. Does it in both IE7...
6
by: raknin | last post by:
Hi I am running ajax call to my appache local server on my development server, which is also my testing server, I run the site from the server (the server running php,mysql), what I get back is a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.