Announcement Announcement Module
Collapse
No announcement yet.
Using JQuery Ajax calls to forward to user page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using JQuery Ajax calls to forward to user page

    So, also in our app, after the user has "signed Up" through Facebook or Twitter, is it possible for the Jquery code to receive json of the user.

    Basically we have a client-side templating and a single page app. And I am a little confused on how we can display the template that holds the User form for editing into the page they are in from clicking the button to connect like

    action="/connect/facebook"

    Thanks

    Mark

  • #2
    At the moment, there's no *official* support for using Spring Social connection data in client-side Javascript code. But it could be done in one of two ways:

    - If you want to make direct calls to Twitter or Facebook APIs from the client (either via jQuery or via the provider's own JS API), you'll need to get the access token from the server side to the client side somehow to be able to properly construct the requests. This is a bit hackish, though.
    - It's a bit more work, but I believe the best way is for you to provide your *own* REST API that the client talks to. That API would then make the calls to FB or Twitter from the server-side on behalf of the client.

    Bringing Spring Social forward in the stack to the client-side Javascript code is something that I've been thinking a lot about lately. I have no specific plans at this time, but I hope to have a more complete answer for you sometime in the future.

    Comment


    • #3
      It makes for a very interesting problem/solution/challenge. In the case for a single page web app.

      Because, inherent to connect or login with social is a redirect to the social's network pages. Which is also part of why people use this is that their social credentials are not given to our apps, but only to the social network in questions. And therefore the original page is gone and would need to be reloaded, and therefore no longer a single page app. Also, if it was coded as such, then there would need to be code in the onload that checks to see if this is the first real load of that page, or is this a redirect back from the social network and there is information available to look at in the onload javascript code to then change the page. (I am using Mustache/ICanHaz.js client side templating)

      I really do dislike jsp pages, I definitely don't include jstl in my page, or any tag library except Spring Security taglib.

      But it seems like the only solution for now is to have a separate jsp page for the account page, which has to look identical to the index page, but then there is a problem since the index page has all the javascript all the templates etc.

      Ok, how does this sound? Create a Controller method that takes the callback from social instead of having a connectFacebook.jsp, just the Controller RequestMapping to it, then put a flag in the model, and forward to the index page, that my index page looks for the flag and if it sees it render the template(call another Javascript function)

      Thanks

      Mark

      Comment

      Working...
      X