I am trying to get a html response from a controller with a link cm-ajax request. My attempts failed
I created a new addon and orders.post.php to extend the controller with a new mode for the backend.
This mode gets called with a link in backend:
<a class="cm-ajax" data-ca-target-id="div_container" href="{'orders.new_mode'|fn_url}">ajax link</a>
```<br />
<br />
If i execute fn_set_notification in the controller it works (it created a message popup), but I dont get the controller to give a response to the page it has been clicked for using it as html for the specified div_container id.<br />
<br />
I am kindly thankfull for a explaination how to do it!<br />
<br />
Kind regards
The way ajax works in cs-cart is that it renders the page identified in the 'mode' of the request. The javascript for cm-ajax will take this response and strip it to all but the result_ids (but you need a comment before the closing tag of the id of the tag). Those elements are then put into the DOM.
What is the XHR “response” in your browser? You really have to look at examples from existing code in the cart. Can't write a tutorial on the various options based on class names.
Great thx for this info, putting the did gave me a html response into my div id container which was defined in the related controller view.
There is one big problem for sending form data: in the backend orders.manage I want to send some input textbox values + textarea values, but it is not possible to add them to a form due to the whole page allready is in a form (putting a form into a form does not work in html), is there a solution for it ?
This form is listed in the Addon Tab. The cm-ajax link should auto grab the current input values and send them by ajax.
this is orders.manage for backend. I just want to send the values to a custom created controller which executes a function with it.
The Problem is: how to auto add the input values (must be live-data as the text inputfield can be changed) to the cm-ajax request.
The Form-POST method doesnt work as the backend orders.manage allready is a form. Can I give a special name to the input fields so they get automaticly send with clicking the cm-ajax link => GET request ?
sorry, I must be thick. What you are wanting to do and your approach to doing are not making sense to me. Ajax and GET?
Why not just add your fields via a hook and then use a checkout.pre.php controller to capture their values when the checkout is posted in it's normal way? I think you are over complicating the problem. But maybe I'm missing something.
In Backend Dispatch: “orders.manage” I have added a new Addon to the the Addons Tab which shows 2 input fields and a send button:[list]
[]SMS-Number => Input Textbox
[]SMS-Text => Textarea
[*]Send-Button => a href with class “cm-ajax”
[/list]
When clicking the send Button the SMS-Number & SMS-Text need to be given by ajax to the new Controller “mycontroller.sendsms”. Which than executes a function defined in func.php and returns “OK” to the backend page.
Indeed it is possible to create a GET request in the cm-ajax link with onclick jquery fetching the values of the SMS-Number & SMS-Button. But this is not the easy way so I wonder if there is a fast solution ?
I've never worked with microformats, but I know how I'd solve this:[list=1]
[]Add your fields via hook to the admin
[]Add some javascript that makes use of $.ceAjax to send whatever you wanna send to PHP (see below)
[]Do whatever you want in PHP and attach your response to Registry::get('ajax')->assign('key', 'value'); and exit; so it won't look for a template.
[]Use the callback of $.ceAjax to display the response in your template.
[/list]
Here's a basic $.ceAjax function:
$.ceAjax('request', fn_url('dispatch.mode'), {
cache: false,
data: {'key': 'value','add': 'some more'},
callback: function(data) {
// Do something with your data, such as $('#attach_me_here').append(data);
}
});
[color=#282828][font=arial, verdana, tahoma, sans-serif]but if you want set a Smarty variable, that you will use in your template, you should write:[/font][/color]
I want to dynamic drop down list of states,districts and centers using database. I have seleted one state and next drop-down displayed to related districts.My problem is "How to call controller using ajax". Please shown following code.
code:-
{_("State")}:
Select state
{foreach from=$dym_states item="states"}
{$states.state_name}
{/foreach}
{_(“District”)}:
Select district
{foreach from=$dym_districts item=“districts”}
{$districts.district_name nofilter}
{/foreach}
on the order detail page in admin panel there is a button new shipment, on clicking it popup opens.. i have added one button on it. on clicking that button it should go to controller and return back on the same popup with some value.. to do so what should i write in the return url?? or should i return the controller back to the popup??
Generally you set the result_ids variable in the POSTed data to be the id of the div you want to redraw when the AJAX request responds with html (template).