I want to open profile page like www.website.com/slim/username
(where username
is unique) .
I am currently using slim php
framework for routing GET
requests. So when I open www.website.com/profile/username
it properly executes the route defined for /username
and gives simple json response like this
{"users":[{"id":"01","firstname":"kamron","lastname":"shaw","gender":"male","status":"Offline"}]}
From this point I wanted to integrate this data with the profile page template, so I made a profile page template at www.website.com/profile.php
and from there used ajax
to make a GET
request towww.website.com/slim/username
and receive data and display it with template.
Problem is that if a user navigates directly to www.website.com/slim/username
, he will only see the raw JSON
response.
I want users to see the JSON
response with template when they directly make a GET
request from there browser.
How can I achieve this? Please correct me if I am wrong anywhere and tell me a suitable way of doing this.