Mac Dashcode Ajax request issue.

Killyp

macrumors 68040
Original poster
Jun 14, 2006
3,860
5
I have been trying to create a widget to request a server and display the number of email messages you have using Dashcode.

However, the XMLHTTP request object seems to be aborting before doing anything. The readystate property is set to 4 and the status is set to 0, According to what I have discovered from the internet, this means it has aborted. I am sure my URL is correct, yet it still won't work.

Here is my code:

Code:
var xmlhttp = create_object(); //this creates the xmlhttprequest object, I know this works as its been tested in browsers, safari (3), firefox and IE
	xmlhttp.open('POST', 'http://boshty.co.uk/mail/list_messages.php', true);
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{
			if (xmlhttp.status == 200)
			{
                               //request worked
			}
			else
			{
				//error, this is where we always end up. Ready state 4, status 0.
			}
		}
	}
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); //because we are sending data
	xmlhttp.send("f=inbox"); //this needs to be sent.
Thanks in advance :)
 

superbovine

macrumors 68030
Nov 7, 2003
2,872
0

linuxftw

macrumors newbie
Jun 25, 2007
10
0
It seems XMLHTTP Request object gives no error. It just aborts.

Is there any way I can extract an error from it?
 

inCider

macrumors newbie
Mar 23, 2007
9
0
Make sure you are allowing for network access

Make sure you are allowing for network access in your Info.plist file:

<key>AllowNetworkAccess</key>
<true/>

HTH,
inCider