Jump to content

multiple connections


tinker

Recommended Posts

i'm very self taught with ajax, i found an example which said this is how complicated it wasn't, the rest was up to your protocol...

 

The problem i get is when upon loading a new page, say a connection sends a msg, then another is sent upon the send returning, however i get errors:

Error: uncaught exception: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]"  nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)"  location: "JS frame :: http://127.0.0.1/ajax/index :: ajax_send :: line 279"  data: no]

This error is always from the second send...

 

 

this is some of the connection code (i assume it's tcp, however can it handle sending another msg before the last returns?):

function ajax_create_conn()
{
	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		try
		{
			ajaxconn=new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (e)
		{
			try
			{
				ajaxconn=new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch (e)
			{
				alert('Your browser does not support AJAX!');
				ajaxconn = null;
			}
		}
	}
	else
	{
		// Firefox, Opera 8.0+, Safari
		ajaxconn = new XMLHttpRequest();
	}
	return;
}

function ajax_send(cmd)
{
	if(ajaxconn != null)
	{
		ajaxconn.onreadystatechange = ajax_handle_conn;
		ajaxconn.open('get', '".$loc."?cmd=' + cmd);
		ajaxconn.send(null);
	}
}

function ajax_handle_conn()
{
	if(ajaxconn.readyState == 4)
	{
		var response = ajaxconn.responseText;
		//...
	}
}

Link to comment
Share on other sites

OK, some searching and I find that firefox trips when trying to make multiple connections... strange because once it's going it handles it fine, anyway i've set a second set of connection handlers which seems far from ideal. However I now expect that I might need to set up a third connection set.

 

I'm going to do some tests to see if I just need a separate handler or send function, any wisdom will be gratefully received...

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.