Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4009210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:51:00+00:00 2026-05-20T08:51:00+00:00

I have been killing myself over this for some time. I am looking to

  • 0

I have been killing myself over this for some time. I am looking to use the causes API to fetch some data from some of our causes we have active and display that via html.

I have created a facebook app and i’m trying to use jquery ajax. This is what I have:

<script type="text/javascript">
$(document).ready(function()
{
  $.ajax({
    url: "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fapi.causes.com%2Fbeneficiaries%2F1239.xml'&format=json&callback=cbfunc",
    dataType: "json",
    success: function(cbfunc) {
        $(cbfunc).find('count').each(function(){
            var total = $(this).find('total-raised').text();
            $(this).html('<p>'+total+'</p>').appendTo('#listTotalDollor');
        });
    }
  });
});

Problem is that I am not getting anything to display. Is this a crossdomain issue or is there something I missed.

Thanks!

Updated code:

<script type="text/javascript">
$(document).ready(function()
{
  $.ajax({
    url: "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20json%20where%20url%3D%22http%3A%2F%2Fapi.causes.com%2Fbeneficiaries%2F1239.json%22&format=json",
    dataType: "json",
    success: function(data) {
        $.each(data.query.results, function(i, key) {
            var total = key['total_raised'];
            $("#listTotalDollar").html('<span>' + total + '</span>');
        });
    }
  });
});

One last question to ask:

If I wanted to format one of the returning values as currency.

In my updated code I get a return of 5000 I would like it to read $5,000. Is there a good tut you can point me to?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:51:00+00:00Added an answer on May 20, 2026 at 8:51 am

    You are mixing DOM and JSON access in you cbfunc. Assuming, that you want that total-raised number for each of the elements returned by that query, you can simple request JSON (as you do) and iterate over it accordingly.

        $.ajax({
            // !wrapped only for readability!
            url: "http://query.yahooapis.com/v1/public/yql?
                      q=select%20*%20from%20xml%20where%20url%3D'\
                      http%3A%2F%2Fapi.causes.com%2Fbeneficiaries%2F1239.xml'\
                      &format=json",
    
            dataType: "json",
            success: function(data) {
                // `data` is actually a json structure (as requested)
                // if you want to see it as a whole, just use 
                // console.log(data);
    
                // now iterate over the json structure 
                // (see also: http://stackoverflow.com/q/1078118/89391)
                // and set your target dom element as you like 
                // (this is just a dummy ...)
                $.each(data.query.results, function(i, key) {
                    var total = key['total-raised'].content;
                    $("target").html('<p>' + total + '</p>');
                });
            }
        });
    

    Here’s the code I used for debugging: https://gist.github.com/850148.
    For reference, here’s a sketch of the response:

    Object
        query: Object
            count: 1
            created: "2011-03-01T23:24:18Z"
            lang: "en-US"
            results: Object
                beneficiary: Object
                    id: Object
                    name: "INTERNATIONAL FELLOWSHIP OF CHRISTIANS & JEWS"
                    recent-facebook-donors: "time1297716630facebook_id0nameRobert \
                Alan Schoonoveramount200time1297372019facebook_id0nameCurtis En…"
                    total-causes: Object
                    total-donors: Object
                    total-members: Object
                    total-raised: Object
                __proto__: Object
            __proto__: Object
        __proto__: Object
    __proto__: Object
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been looking on some tutorials for drawing canvas using SurfaceView, but the only
I have been using TortoiseSVN for some time and I really like it. I
I've been killing myself all day for this one bug. I can't tell you
This has been killing me for two days now. I have a main Activity
This has been killing me for two days now. I have a main Activity
This has been killing me - I have a massive file that I need
This has been killing me.. Because its a memory management issue... I have a
This problem has been killing me for the entire day. I have a client
This problem is really killing me, I have been googling for a VERY long
Have been working on this question for a couple hours and have come close

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.