If my site uses the Parse.com PHP API to authenticate users, can I use the Javascript API for ajax requests in such a way that the user, having been logged in via PHP, can access data via the Javascript API?
What would I need to set up differently?
Some background
I have a site that uses the Parse.com PHP API to handle all backend tasks like storing and retrieving data and authenticating users.
I have several pages that use ajax to refresh page content.
I have written my own Javascript class for sending JSON data to my server via ajax where the info is processed and my PHP code steps in to create, update, or delete Parse objects as needed.
This all works very well with the exception of dealing with files. I see several approaches to dealing with files but I feel like I'm re-inventing the wheel.
The Parse.com Javascript API is great, I'm pretty familiar with it and it already deals with files really well. It would be awesome If I could use it for the ajax.
I have tried...
Logging in with the PHP API and then attempting to use the Javascript SDK directly to get the current user like
var currentUser = Parse.User.current();
if (currentUser) {
// do stuff with the user
alert(currentUser);
} else {
// show the signup or login page
alert('that didnt work');
}
This did not work.