Jump to:

23001 Posts in 11702 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Can I use jQuery.ajax() request?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 3497 Views
  • t_agga
    Avatar
    Community Member
    7 Posts

    Can I use jQuery.ajax() request? Link to this post

    Hi guys,

    I'm aware that I can use jQuery.load() request, but I need my js to trigger another function on success. Is there any way to do it in silverstripe?
    What I'm trying to do is to get projects from my database based on their type. User selects the type of the project from the menu (on click), which in turn is passed to the php function. So far I managed to do it with jQuery.load(). However, I need the php function to return back to the template the result of this query and on success js function should update the template.
    Do you have any idea how it can be done?

    Thanks in advance,
    Aga

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Can I use jQuery.ajax() request? Link to this post

    Hi

    Hm. What Version of jQuery are you using? The $.load() function does have an optional callback function, so you should be fine with that.
    See: http://docs.jquery.com/Ajax/load#urldatacallback

    Or just use the $.get function:
    http://docs.jquery.com/Ajax/jQuery.get#urldatacallbacktype

  • t_agga
    Avatar
    Community Member
    7 Posts

    Re: Can I use jQuery.ajax() request? Link to this post

    Thanks Banal,

    I use quite an old version of jQuery, as it has been given to me along other js files. I've just realized that it's very old!!!(jQuery 1.1.4 ). I will try it with the new version and will let you know about my findings. Thanks for your reply, I really appreciate it.
    Aga

  • t_agga
    Avatar
    Community Member
    7 Posts

    Re: Can I use jQuery.ajax() request? Link to this post

    Hi Guys,

    For all of you newbies like me having similar problem, just wanted to let you know that silverstripe works beautifully with ajax() request and other requests provided by JQuery. My mistake was in the way I entered the url. I simply pointed to the class then function instead of specifying just the function name. Check Ajax basics in recipes to clarify the issue. Hope, this will save some of you lots of time as oppose to me.
    My website is almost ready ))

    Aga

  • Matt Howard
    Avatar
    Community Member
    3 Posts

    Re: Can I use jQuery.ajax() request? Link to this post

    Hey, I've been puzzling through the Recipes:Ajax tutorial and cannot seem to get it to work. I was wondering if you have a live example of your work with Jquery requests.

    Any pointers?

    Thanks,
    -Matt

    3497 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.