3510 Posts in 770 Topics by 480 members
Jump to:If this is your first visit, you will need to register before you can post. However, you can browse all messages below.
| Page: 1 | go to end | Reply | |
| Author | Topic: AJAX and maybe stupid php question... | 7591 views |

18 May 2008 at 12:00am
Hi
sorry for that maybe stupid question.
i 've read
http://doc.silverstripe.com/doku.php?id=recipes:ajax_basics
but don't understand this thing totally.
and i didn't do any ajax things before, so i'm a rookie in this area.
(1) what ist this
Director::is_ajax()
call for?
(2) i have some client-script code not originating from silverstripe that want's to be connected to same ajaxified controller functions.
is there any additionally need to do on a controller-function to act as some client-script expects it to be a ajax-pendant?
(must there be some protocol-header set or anything else)
do i have to include this
Requirements::javascript('mysite/javascript/jquery.js');
if i don't do things for silverstripe ajaxified controls?
let's say, that if i don't need any template rendering things.
so i thought the simplest solution was to return the strings i need.
fe:
if i call this thing in the webbrowser via url it seems to be ok.
if i call it out of a javascript to replace someones innterhtml i have problems
if this thing hase special HTML characters.
they come as XML where they should be HTML... which leeds to javascript-errors
what i don't understand is, what system-part does this xml-translation thing, if i don't use that template rendering mechanism?
Do i have to call another function to encode to another format?
(3) now for the stupid php question:
i've seen this thing sometimes in code, but can't the hell figure out what it does.
(try to search for <<< in google. aaarghhh...)
i think it does something like format it ready for HTML.
but i'm not sure, might also only be some php-syntax construct to allow many lines
of text to be entered in a friendly way.
Last edited: 18 May 2008 at 12:22am

18 May 2008 at 1:57pm
Hi Zyko,
in response to your questions: Director::is_ajax() is used to tell if the SilverStripe instance running has been called by an ajax request, rather than just a normal HTTP request. With the <<< thing, it means that you can specify a custom endpoint for your string, that is instead of:
you can use:
Basically it tells PHP to keep reading the string in until it finds an instance of bla at the beginning of a line (or whatever delimeter you specify after <<<).
As for the special characters, im not 100% sure, but maybe you could try replacing the return with an echo (not a good coding practice - but just as a test) to see if that works.
Last edited: 18 May 2008 at 1:58pm

18 May 2008 at 9:00pm
Hi Grayzag
THX for (3) :-))) makes things clearer for me
(1) would be interesting to me, how this was implemented.
Are there other protocols used, where they take out this info?
but might look myself in code to find out ;-)
(2). I'd some problems understanding the sample in
http://doc.silverstripe.com/doku.php?id=recipes:ajax_basics
the most confusing part for me was that the index-function uses
AAARGHHH...
wondering how silverstripe is doing this (have to look at JQuery)...
g
Helmut
Last edited: 18 May 2008 at 11:23pm
| 7591 views | |||
| go to top | Reply |