A word of caution if you use this on a TWiki site together with the
BlackListPlugin: The plugins bumps you on the blacklist if you save a page that contains a
escape() JavaScript function, as is the case in these examples. You are OK of your IP address is on the whitelist.
--
Peter Thoeny - 2011-01-09
I know this might not be the right place to ask, but if I want to replace the TML in this tutorial with PHP, should I simply define all the PHP variable on a page load and use php tags (<? ?>) to put them in the Javascript? (is that all there is to it or would I be forgetting something important?)
I'm fairly familiar with PHP, but am far from earning a 'PHP expert' title. I'm just asking to be safe, for the moment it seems to be working this way with for small scaled example projects.
--
Chris Ankomah - 2012-07-10
Chris: Yes if you are referring to the Ajax example script. This script runs server side, like your PHP. No change is needed on browser side except for the script URL.
--
Peter Thoeny - 2012-07-11
Thank you! This example has been very helpful. Indeed, changing the scriptUrl was enough.
(In case anyone who passes this thread is wondering how to sub the TML with PHP in this example:)
After that I could just check the value of demo by checking it with if(isset($_POST['demo'])) and by echoing the result of my script aftwerwards.
--
I've got another question about defining the value of the form though: If I want to post more than 1 value, could I simply use a comma and duplicate the sentence 'this.form.df1.value' inbetween the escape brackets?
For example:
[code] onchange="JavaScript:ajaxCall(\'/demo/twikiExample.php\', \'dfilter=\' + escape( this.form.demo.value, this.form.demo2.value ), \'result4\' )" [/code]
Because I have two selection (dropdown) menu's of which I need both values. The problem is that when I try the code I suggested above, I only receive the value of the first selection menu, and when a new selection is made from the menu's, this value isn't refreshed.
Does the refreshing not occur because I'm using a PHP file? Or do I need to add a couple of lines to the AJAX function in order for it to refresh the value('s) onchange?
I'm sorry to bother you with questions like this It's just a problem I can't seem to get my head around and has bee driving me nuts trying to figure it out all day...
--
Chris Ankomah - 2012-07-12
Sorry for bothering you.... The refresh is definitely happening, I just forgot to replace the placeholder code I put in the other selection menu items with the code I mentioned in my previous comment.
Though I still only receive only 1 value (of the first selection menu).
--
Chris Ankomah - 2012-07-12