Jump to content

AJAX JS Nesting Limit?


GargantulaKon

Recommended Posts

I am the type of person to try everything before giving up, but I have reached that point.

 

I realized that I need to add a switch statement to expand my code and this issue is causing me headaches.

 

I even tried passing the arguments to a function and that still does not get processed. IE 8 debugger goes to the function and never steps into it. This does not work in Firefox 3.5 either.

 

I debugged with IE 8 tools with breakpoints and it seems the code does not want to go into the switch statement even if the variable matches a specified case. I have no idea why. I tried if statements too.

 

Is there a nesting limit with JS?

 

function SoMoodee_Mail(Mode, Mail_ID)
{
xmlhttp = GetXmlHttpObject();
if (xmlhttp == null)
  {
	  alert ("Browser does not support HTTP Request");
	  return;
  }
var url = "/SoMoodee_Mail_AJAX/";
url = url + "?Mode=" + Mode + "&Mail_ID=" + Mail_ID;
url = url + "&sid=" + Math.random();

switch(Mode)
{
	case "Delete":
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState <= 3)
			{
				document.getElementById("Status_Mail_" + Mail_ID).style.display = 'block';
			}

			if (xmlhttp.readyState == 4)
			{
				var Response = xmlhttp.responseText;
				var Total_Mail_Count = parseInt(document.getElementById("Total_Mail_Count").innerHTML);
				var Unread_Mail_Count = parseInt(document.getElementById("Unread_Mail_Count").innerHTML);

<?php /* This works at least...since I am outputting a number to subtract 0 or 1 */ ?>
				document.getElementById("Total_Mail_Count").innerHTML = Total_Mail_Count - 1;
				document.getElementById("Unread_Mail_Count").innerHTML = Unread_Mail_Count - Response;

				<?php /* For some reason the javascript dies and never into the function even if true. */ ?>
				switch (Response)
				{	
					case 'Read':
						Total_Mail_Count = Total_Mail_Count - 1;
						document.getElementById("Total_Mail_Count").innerHTML = Total_Mail_Count;
						alert(Response);
					break;

					case 'Unread':
						Total_Mail_Count = Total_Mail_Count - 1;
						Unread_Mail_Count = Unread_Mail_Count - 1;
						document.getElementById("Total_Mail_Count").innerHTML = Total_Mail_Count;
						document.getElementById("Unread_Mail_Count").innerHTML = Unread_Mail_Count;
						alert(Response);
						break;
					default:
				}

				<?php /* Nice fade out effect for IE and Firefox */ ?>
				fade("Message_" + Mail_ID);

			}
		};
	  break;
	case "Reply":
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState <= 3)
			{

			}

			if (xmlhttp.readyState == 4)
			{
				document.getElementById("Add_SoMoodeean_Button").innerHTML = xmlhttp.responseText;
			}
		};
	  break;
	default:
}

xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.