How do I Use Ajax to grab Blogger data

0 favourites
  • 4 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Goal: Figure out how to read RSS or ATOM Feed from blogspot and output XML content to inform users of future updates & news, along with quick messages to the user base.

    The Problem I am having: getting nothing but the "on ajax error" exception I put in to change the bg color & text.

    I am trying to grab it from this feed:

    http://undeadbobop.blogspot.com/feeds/posts/default

    Which is more clear with online xml formatters, which shows I need to grab from feed/entry/title & feed/entry/content.

    Basically I am trying to make a RSS feed reader and I don't see what I am doing wrong.

    Link to source: https://www.dropbox.com/s/z8hs1ucncmvn8bo/xmltry.capx?dl=0

    And Yes I am trying it inside exported projects too.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Normally you cannot grab data by AJAX from different domain than the one the request is triggered from. So if you are trying to fetch data across different domains you need to tell your webserver to allow it.

    If you use Apache then simply create .htaccess file and put the following line inside:

    <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
    </IfModule> [/code:3anofexg]
  • Well thank you for telling me this, it isn't much help since I don't have a webserver and most webhosts won't allow you to configure it unless you pay for them.

  • You can do a workaround with a small PHP script.

    <?php
    header("Access-Control-Allow-Origin: *");
    $rss = file_get_contents('http://undeadbobop.blogspot.com/feeds/posts/default');
    die($rss);
    ?>[/code:qkpa54jm]
    
    Now you can grab your PHP file with AJAX in C2. The result will be the same.
    
    EDIT: I'm sure both solutions will work on most of free PHP servers.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)