http://angularjs.org/Service:$xhr

75 views
Skip to first unread message

Jerry

unread,
Oct 17, 2010, 7:21:33 PM10/17/10
to Angular

Why doesn't the example at http://angularjs.org/Service:$xhr work?
Is it just me? I click the "buzz" link to fillt the form. Then I
click fetch. Nothing happens.
What am I doing wrong?

Thanks,

Jerry

John Hardy

unread,
Oct 17, 2010, 11:32:35 PM10/17/10
to ang...@googlegroups.com
Possibly something to do with the notice from the other day? Check the archive for:

"BACKWARD INCOMPATIBLE CHANGE IN ANGULAR"



--
You received this message because you are subscribed to the Google Groups "Angular" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.


Misko Hevery

unread,
Oct 17, 2010, 11:53:50 PM10/17/10
to ang...@googlegroups.com
Thanks for catching this! It is fixed now. Here is what was wrong.

The original code said this:
<div ng:controller="FetchCntl">
   <select name="method">
     <option>GET</option>
     <option>JSON</option>
   </select>
   <input type="text" name="url" value="/rsrc/project.json" size="80"/><br/>
  <button ng:click="fetch()">fetch</button>
  <button ng:click="clear()">clear</button>
  <a href="" ng:click="method='GET'; url='/rsrc/project.json'">sample</a>
  <a href="" ng:click="method='JSON'; url='https://www.googleapis.com/buzz/v1/activities/googlebuzz/@self?alt=json&callback=JSON_CALLBACK'">buzz</a>
</div>
<pre>code={{code}}
response={{response}}</pre>
The issue is that the ng:controller is set on the div, while the pre which shows the results was a sibling to div not a child. This should have never worked except for this bug: http://github.com/angular/angular.js/issues/closed#issue/39 which was recently fixed. The bug basically allowed it so that everyone would see the controller rather then just the child elements. After the bug was fixed you need to change the pre to be a child of the div and everything works fine:

<div ng:controller="FetchCntl">
   <select name="method">
     <option>GET</option>
     <option>JSON</option>
   </select>
   <input type="text" name="url" value="/rsrc/project.json" size="80"/><br/>
  <button ng:click="fetch()">fetch</button>
  <button ng:click="clear()">clear</button>
  <a href="" ng:click="method='GET'; url='/rsrc/project.json'">sample</a>
  <a href="" ng:click="method='JSON'; url='https://www.googleapis.com/buzz/v1/activities/googlebuzz/@self?alt=json&callback=JSON_CALLBACK'">buzz</a>
  <pre>code={{code}}
  response={{response}}</pre>
</div>
-- Misko

Jerry

unread,
Oct 18, 2010, 4:12:47 AM10/18/10
to Angular

Sorry for not knowing what I am doing...
New question: why is stuff being dropped from the "response" as it is
displayed?

If at http://angularjs.org/Service:$xhr I do a JSON request for
http://spreadsheets.google.com/feeds/list/pouqRkV5D_eZT_VdOKu7CQA/od6/public/values?alt=json-in-script&callback=JSON_CALLBACK
I get back:

code=200 response={
"encoding":"UTF-8",
"feed":{
"author":[{
"email":{
},
"name":{
}}],
"category":[{
"scheme":"http://schemas.google.com/spreadsheets/2006",
"term":"http://schemas.google.com/spreadsheets/2006#list"}],
"entry":[{
"category":[{
"scheme":"http://schemas.google.com/spreadsheets/2006",
"term":"http://schemas.google.com/spreadsheets/2006#list"}],
"content":{
"type":"text"},
"gsx$field":{
},
"gsx$html":{
},
"id":{
},
"link":[{
"href":"https://spreadsheets.google.com/feeds/list/
pouqRkV5D_eZT_VdOKu7CQA/od6/public/values/cokwr",
"rel":"self",
"type":"application/atom+xml"}],
"title":{
"type":"text"},
"updated":{
}}],
"id":{
},
"link":[{
"href":"https://spreadsheets.google.com/pub?
key=pouqRkV5D_eZT_VdOKu7CQA",
"rel":"alternate",
"type":"text/html"},{
"href":"https://spreadsheets.google.com/feeds/list/
pouqRkV5D_eZT_VdOKu7CQA/od6/public/values",
"rel":"http://schemas.google.com/g/2005#feed",
"type":"application/atom+xml"},{
"href":"https://spreadsheets.google.com/feeds/list/
pouqRkV5D_eZT_VdOKu7CQA/od6/public/values?alt=json-in-script",
"rel":"self",
"type":"application/atom+xml"}],
"openSearch$startIndex":{
},
"openSearch$totalResults":{
},
"title":{
"type":"text"},
"updated":{
},
"xmlns":"http://www.w3.org/2005/Atom",
"xmlns$gsx":"http://schemas.google.com/spreadsheets/2006/
extended",
"xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/"},
"version":"1.0"}

which doesn't have any of the actual data. But if I execute this:

<html><body>
<div id="headline"></div>
<script type="text/javascript">
function JSON_CALLBACK(json)
{ document.getElementById('headline').innerHTML =
json.feed.entry[0].gsx$html.$t; }
</script>
<script type="text/javascript"
src="http://spreadsheets.google.com/feeds/list/pouqRkV5D_eZT_VdOKu7CQA/
od6/public/values?alt=json-in-script&callback=JSON_CALLBACK">
</script>
</body></html>

I get this (according to Firebug):

JSON_CALLBACK({"version":"1.0","encoding":"UTF-8","feed":
{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://
a9.com/-/spec/opensearchrss/1.0/","xmlns$gsx":"http://
schemas.google.com/spreadsheets/2006/extended","id":{"$t":"https://
spreadsheets.google.com/feeds/list/pouqRkV5D_eZT_VdOKu7CQA/od6/public/
values"},"updated":{"$t":"2007-06-12T16:12:07.006Z"},"category":
[{"scheme":"http://schemas.google.com/spreadsheets/
2006","term":"http://schemas.google.com/spreadsheets/
2006#list"}],"title":{"type":"text","$t":"Sheet1"},"link":
[{"rel":"alternate","type":"text/html","href":"https://
spreadsheets.google.com/pub?key\u003dpouqRkV5D_eZT_VdOKu7CQA"},
{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom
+xml","href":"https://spreadsheets.google.com/feeds/list/
pouqRkV5D_eZT_VdOKu7CQA/od6/public/values"},
{"rel":"self","type":"application/atom+xml","href":"https://
spreadsheets.google.com/feeds/list/pouqRkV5D_eZT_VdOKu7CQA/od6/public/
values?alt\u003djson-in-script"}],"author":[{"name":
{"$t":"todd.huss.work"},"email":
{"$t":"todd.hu...@gmail.com"}}],"openSearch$totalResults":
{"$t":"1"},"openSearch$startIndex":{"$t":"1"},"entry":[{"id":
{"$t":"https://spreadsheets.google.com/feeds/list/
pouqRkV5D_eZT_VdOKu7CQA/od6/public/values/cokwr"},"updated":
{"$t":"2007-06-12T16:12:07.006Z"},"category":[{"scheme":"http://
schemas.google.com/spreadsheets/2006","term":"http://
schemas.google.com/spreadsheets/2006#list"}],"title":
{"type":"text","$t":"headline"},"content":{"type":"text","$t":"html:
Palm releases Linux based \u003ca href\u003d\"http://www.palm.com/us/
products/mobilecompanion/foleo/\"\u003eFoleo\u003c/a\u003e"},"link":
[{"rel":"self","type":"application/atom+xml","href":"https://
spreadsheets.google.com/feeds/list/pouqRkV5D_eZT_VdOKu7CQA/od6/public/
values/cokwr"}],"gsx$field":{"$t":"headline"},"gsx$html":{"$t":"Palm
releases Linux based \u003ca href\u003d\"http://www.palm.com/us/
products/mobilecompanion/foleo/\"\u003eFoleo\u003c/a\u003e"}}]}});

I assume the same stuff is retrieved. So is the databeing saved and
just not shown?

Thanks,

Jerry

Igor Minar

unread,
Oct 18, 2010, 12:03:37 PM10/18/10
to ang...@googlegroups.com
sigh.. that's because we don't jsonify properties that start with $ in the view. So the data is there, it's just not displayed because usually properties starting with $ are angular internals which are not useful for the user to see.

We'll have to rethink this. I opened a ticket: http://github.com/angular/angular.js/issues/issue/65

thanks for the report.

/i


Thanks,

Jerry

Miško

unread,
Oct 18, 2010, 12:29:39 PM10/18/10
to Angular
in other words, the data is there, you just don't see it. :-)

On Oct 18, 9:03 am, Igor Minar <iimi...@gmail.com> wrote:
> sigh.. that's because we don't jsonify properties that start with $ in the
> view. So the data is there, it's just not displayed because usually
> properties starting with $ are angular internals which are not useful for
> the user to see.
>
> We'll have to rethink this. I opened a ticket:http://github.com/angular/angular.js/issues/issue/65
>
> thanks for the report.
>
> /i
>
>
>
>
>
>
>
> On Mon, Oct 18, 2010 at 1:12 AM, Jerry <jerry.jerem...@gmail.com> wrote:
>
> > Sorry for not knowing what I am doing...
> > New question: why is stuff being dropped from the "response" as it is
> > displayed?
>
> > If athttp://angularjs.org/Service:$xhrI do a JSON request for
>
> >http://spreadsheets.google.com/feeds/list/pouqRkV5D_eZT_VdOKu7CQA/od6...
> > {"$t":"todd.huss.w...@gmail.com"}}],"openSearch$totalResults":
> > {"$t":"1"},"openSearch$startIndex":{"$t":"1"},"entry":[{"id":
> > {"$t":"https://spreadsheets.google.com/feeds/list/
> > pouqRkV5D_eZT_VdOKu7CQA/od6/public/values/cokwr"},"updated":
> > {"$t":"2007-06-12T16:12:07.006Z"},"category":[{"scheme":"http://
> > schemas.google.com/spreadsheets/2006","term":"http://
> > schemas.google.com/spreadsheets/2006#list"}],"title":
> > {"type":"text","$t":"headline"},"content":{"type":"text","$t":"html:
> > Palm releases Linux based \u003ca href\u003d\"http://www.palm.com/us/
> > products/mobilecompanion/foleo/\"\u003eFoleo\u003c/a\u003e"},"link":
> > [{"rel":"self","type":"application/atom+xml","href":"https://
> > spreadsheets.google.com/feeds/list/pouqRkV5D_eZT_VdOKu7CQA/od6/public/
> > values/cokwr"}],"gsx$field":{"$t":"headline"},"gsx$html":{"$t":"Palm
> > releases Linux based \u003ca href\u003d\"http://www.palm.com/us/
> > products/mobilecompanion/foleo/\"\u003eFoleo\u003c/a\u003e"}}]}});
>
> > I assume the same stuff is retrieved.  So is the databeing saved and
> > just not shown?
>
> > Thanks,
>
> > Jerry
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Angular" group.
> > To post to this group, send email to ang...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > angular+u...@googlegroups.com<angular%2Bunsu...@googlegroups.com >
> > .

Jerry

unread,
Oct 18, 2010, 5:41:38 PM10/18/10
to Angular

That's all I wanted to know. If I can stick it into a table or form
and use it that's good enough.
It would be handy to see it in the response but absolutely not
necessary.

Thanks so much,

Jerry

On Oct 19, 5:29 am, Miško <mi...@google.com> wrote:
> in other words, the data is there, you just don't see it. :-)
>
> On Oct 18, 9:03 am, Igor Minar <iimi...@gmail.com> wrote:
>
>
>
> > sigh.. that's because we don't jsonify properties that start with $ in the
> > view. So the data is there, it's just not displayed because usually
> > properties starting with $ are angular internals which are not useful for
> > the user to see.
>
> > We'll have to rethink this. I opened a ticket:http://github.com/angular/angular.js/issues/issue/65
>
> > thanks for the report.
>
> > /i
>
> > On Mon, Oct 18, 2010 at 1:12 AM, Jerry <jerry.jerem...@gmail.com> wrote:
>
> > > Sorry for not knowing what I am doing...
> > > New question: why is stuff being dropped from the "response" as it is
> > > displayed?
>
> > > If athttp://angularjs.org/Service:$xhrIdo a JSON request for
> > >http://groups.google.com/group/angular?hl=en.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages