Ajax call and action with parameter.
Permalink
Hi Guys,
I'm a newbie of ajax and concrete5 adn I'm hoping that someone knows the answer on my problem. I followed Andrew Embler's tutorial about ajax and it's working fine. The problem is I wanted my function to have one parameter like below.
on controller.
on edit.php
on auto.js
I wonder how can I pass an argument on my action test using the method that I presented above. Thank you.
I'm a newbie of ajax and concrete5 adn I'm hoping that someone knows the answer on my problem. I followed Andrew Embler's tutorial about ajax and it's working fine. The problem is I wanted my function to have one parameter like below.
on controller.
on edit.php
$action = $this->action('test'); <a id="test_action" href="<?php echo $action; ?>">Ajax Call;</a>
on auto.js
I wonder how can I pass an argument on my action test using the method that I presented above. Thank you.
@JohntheFish, you're right, it fails on add. How do I do this on Add/Edit form of the block?
P.S. I was able to append a Get Param on the url, it works as usual as GET method. I thought there's a special way of doing it. :)
P.S. I was able to append a Get Param on the url, it works as usual as GET method. I thought there's a special way of doing it. :)
You need to call out to a tool file, which is one of the examples in AJAX lessons.
Thank you for your help so far, it is working. Iw as able to create a tool file and url was constructed. Unfortunately using the code I posted above on my auto.js. It's not returning anything on the response.
But the url is correct because when I removed return false; it's being directed on the the tool file.
THis behavior is the same on the Ajax lesson. YOu mentioned that I needed to create a ccm_token myself? May you please give me an idea on how to do that. Thank you.
But the url is correct because when I removed return false; it's being directed on the the tool file.
THis behavior is the same on the Ajax lesson. YOu mentioned that I needed to create a ccm_token myself? May you please give me an idea on how to do that. Thank you.
What you need to look up is:
You use this in a block to create an encrypted token, then again in a tool to check the validity of that token.
PS:
http://www.concrete5.org/documentation/developers/forms/basic-valid...
Loader::helper('validation/form')
You use this in a block to create an encrypted token, then again in a tool to check the validity of that token.
PS:
http://www.concrete5.org/documentation/developers/forms/basic-valid...
Also, beware of doing this in an edit dialog. The ajax could fail during the initial add of the block becuae the bID does not yet exist.
See AJAX Lessons
http://www.concrete5.org/documentation/how-tos/developers/ajax-less...
and the associated addon
http://www.concrete5.org/marketplace/addons/ajax-lessons/...
Its getting a bit old now, but the principles remain the same.