Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Can I use jQuery.ajax() request?


Go to End


5 Posts   4792 Views

Avatar
t_agga

Community Member, 7 Posts

4 April 2009 at 4:08am

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

Avatar
bummzack

Community Member, 904 Posts

4 April 2009 at 5:35am

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

Avatar
t_agga

Community Member, 7 Posts

9 April 2009 at 10:48pm

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

Avatar
t_agga

Community Member, 7 Posts

8 May 2009 at 2:03am


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

Avatar
Matt Howard

Community Member, 3 Posts

17 September 2009 at 6:47am

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