XUI and XHR

114 views
Skip to first unread message

Tom Krones

unread,
Sep 17, 2010, 5:43:34 PM9/17/10
to phonegap
I've been trying to get xhr from xui to work with my project. I'm
currently converting my code from jQuery to XUI. This is the code
that I use and works with jQuery:

var good = function() {
alert("good");
};

var bad = function() {
alert("bad");
};

$.ajax({
type: "POST",
url: "http://site.com/WebService.asmx/getBusiness",
data: "{'busID': '30'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: good ,
error: bad
});

This is what I've been trying but haven't gotten it to work.

x$(window).xhr('http://site.com/WebService.asmx/getBusiness', {
method:'post',
data:"{'busId': '30'}",
headers:{name:'Content-type', value: 'application/json;
charset=utf-8'},
callback: good
});

I downloaded xui-more-1.0.0.min.js from http://xuijs.com/. Should I
download the latest edge from http://github.com/brianleroux/xui ?

Thanks in advance.

Tom Krones

unread,
Sep 18, 2010, 2:22:13 PM9/18/10
to phonegap
I've made some progress but I'm still have a few issues. When running
the code the same domain as the url I have success with this code:

var good = function() {
alert(this.responseText);
};

x$(window).xhr('http://site.com/WebService.asmx/getBusiness', {
method:'post',
data:"{'busID': '30'}",
headers:[{name:'Content-type', value: "application/json;"}],
callback: good
});

Woohoo! Yeeeaaaa!! Boooyaa!!! :D

Now for the problem. When I run the code from lets say, localhost or
another domain I get the error:
NETWORK_ERR: NETWORK_ERR: XMLHttpRequest Exception 101

I'm testing the code using Chrome on Windows 7. Is this the right way
to test it? Has anyone else had this issue?

Thanks
> I downloaded xui-more-1.0.0.min.js fromhttp://xuijs.com/.  Should I

Jesse

unread,
Sep 18, 2010, 10:03:06 PM9/18/10
to Tom Krones, phonegap
You cannot call crossdomain, using any form of xhr.

This is not a restriction for pages loaded from the file:// protocol as phonegap apps are intended to work.

Sent from my iPhone

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com

Tomas Krones

unread,
Sep 18, 2010, 10:20:23 PM9/18/10
to Jesse, phonegap
Thanks. I'm new to the cross domain calls. I did more reading and understand it much better.

Thanks again.

Tom

Brian LeRoux

unread,
Sep 19, 2010, 10:56:40 AM9/19/10
to Tomas Krones, Jesse, phonegap
try running in a webkit (or safari) if you wanna do your dev in a
browser. it allows cross domain.
Reply all
Reply to author
Forward
0 new messages