onreadystatechange not changing?

Community based support for the Digium Phone Application Programming Interface (API).

Moderators: jwitt, sruffell, malcolmd, Moderator

onreadystatechange not changing?

Postby fransena » Mon May 27, 2013 7:37 am

Here's my code:

function init() {
var request = new NetRequest();
request.open("GET", "<myurl>");
util.debug('Starting Request');
request.onreadystatechange = function () {
util.debug('State Changed');
}
}
init();

The second util.debug never executes, yet if I go to the url manually in a browser (<myurl> is just a placeholder for this posting) it returns the required text.

I know it works, since the weather widget works, but for the life of me I can't figure it out...
fransena
Newsterisk
 
Posts: 15
Joined: Tue Jul 22, 2008 2:49 pm

Re: onreadystatechange not changing?

Postby mollett » Tue May 28, 2013 6:12 am

Are you executing request.send()? The request will never be sent to the web server if that isn't called. It's easy to forget (don't ask me how I know)!
mollett
Newsterisk
 
Posts: 25
Joined: Mon Apr 01, 2013 12:03 pm

Re: onreadystatechange not changing?

Postby fransena » Tue May 28, 2013 6:16 am

Well I'll be darned. That worked. And yet the documentation states:

(send) Initiates the request. The optional argument provides the request entity body. The argument is ignored if request method is GET or HEAD.

I guess I got confused. Thanks!
fransena
Newsterisk
 
Posts: 15
Joined: Tue Jul 22, 2008 2:49 pm

Re: onreadystatechange not changing?

Postby mollett » Tue May 28, 2013 6:22 am

I think it's stating that the argument to the send() method is optional, not that invoking the method is optional.
mollett
Newsterisk
 
Posts: 25
Joined: Mon Apr 01, 2013 12:03 pm

Re: onreadystatechange not changing?

Postby fransena » Tue May 28, 2013 6:29 am

Yeah, and I feel a bit foolish that I misread it. It's always the simple things, isn't it?!
fransena
Newsterisk
 
Posts: 15
Joined: Tue Jul 22, 2008 2:49 pm


Return to Digium Phone API

Who is online

Users browsing this forum: No registered users and 1 guest