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
https://forums.phpfreaks.com/topic/101469-multiple-connections/
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
https://forums.phpfreaks.com/topic/101469-multiple-connections/#findComment-519073
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.