Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


jquery ajax php json fetch -- help...

Hi I'm trying to get the data I fetch using PHP.

the page is named twitter-fetch.php

now what I know is, that page is now filled with json data converted to associative array because I json_decode() on the the data. (please correct me if I'm wrong).

now what I'm trying to do is calling that page using ajax.

the name of the project is phone. the my js file is in the js folder. and the twitter-fetch.php is in php folder. I just want to see the result in console for now, help... :(

I'm still new to ajax and json so I'm really not sure on what I'm doing here

        url: '/phone/php/twitter-fetch.php',
        contentType: 'application/json',
        dataType: 'json',
        success: function(result){

this the php line where I used the json_decode and stored it in $string

    $string = json_decode($twitter->setGetfield($getfield)
    ->buildOauth($url, $requestMethod)
    ->performRequest(),$assoc = TRUE);

1 Answer

I'm quite sure the problem is in the URL. Check it according to where the index.php file is coming from.