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

PHP

Get frontend website ready for backend

I'm working with a backend dev on a website. I'm the frontend guy so I created some AJAX requests to update the content of the page and created some JSON mockup files.

However, the backend guy has just told me that he doesn't know why it would be in JSON format, and that he will serve the content from the backend as plain text (He is using PHP).

What do I do to get the frontend ready for this? I'm so lost...

2 Answers

Andrew Shook
Andrew Shook
31,709 Points

Are you using a front end framework like angular, and what do the ajax calls do?

No, I'm not using a framework. Just using javascript with some jQuery. The Ajax is used to update the content of the page with the mock JSON file I made:

var url = 'js/pages/applicationInfo.json';
var data;
var callback = function (response) {
    $.each(response, function (index, value) {

            $('#application-info #title').html(value.title);
    });
};

$.get(url, callback);
Andrew Shook
Andrew Shook
31,709 Points

When he says plain text what does he mean? Like actual plain text or html? Sorry I was just exhausted yesterday and missed that part of your question. Now it makes a lot more sense.

Hi, thanks for your replies.

He basically wants me to link it up so he can do his php stuff. I've never done it anyother way but JSON so I've just left it like this for him:

$.ajax({
    type: 'GET',
    url: '',
    data: '',
    success: function (response) {
        $('#application-info #title').html();

    }
});

I'm guessing he will put a value within the .html(??). Or do I do response.title or something?? I hope that makes sense. Thanks again.