Where to place the common ajax functions for shipping module plugin
Where should I place my common ajax functions and can you please give me sample url on ajax calls?
I have got a new shipping methods but I don't know where should I place the ajax related functions specific to my plugin only? |
Re: Where to place the common ajax functions for shipping module plugin
Please note the following sample ajax call code. I have to use autocomplete jquery library thatswhy I am doing it normal jQuery way instead of some conventional X-Cart way:
jQuery("document").ready(function(){ jQuery("#shippingaddress-city").autocomplete('test', { extraParams: { countrycode: function() { return jQuery("#shippingaddress-country-code").val();}, city: function() { return jQuery("#shippingaddress-city").val(); } }, minChars: 0, max: 200, multiple:false, scrollHeight: 220, autoFill: false, mustMatch: false, selectFirst:true, cacheLength:1 }); jQuery("#shippingaddress-zipcode").autocomplete('test', { extraParams: { countrycode: function() { return jQuery("#shippingaddress-country-code").val();}, zip: function() { return jQuery("#shippingaddress-zipcode").val(); } }, minChars: 0, max: 200, multiple:false, scrollHeight: 220, autoFill: false, mustMatch: false, selectFirst:false, cacheLength:1 }); }); |
Re: Where to place the common ajax functions for shipping module plugin
I think it may work if you add this js file to the list of js files loaded by the widget class.
However, it would be better if you could wrap it up into a "controller" and make XC5 autoload it - search for "core.autoload(" in other js files. |
Re: Where to place the common ajax functions for shipping module plugin
Sorry for not explaining clearly. I gave the example of jquery because I wanted to insert some xcart specific url to the autocomplete jquery function. So I mean to say that what sort of url should it be. Any example url? And where should I place the php related function which is going to be processed because this url is called.
|
Re: Where to place the common ajax functions for shipping module plugin
It can be any URL pointing to a valid controller class. It's the controller and the view classes that should implement the AJAX logic.
If you need json response, use the WidgetsCollection controller as the example. If you need html response (I believe so), check how the checkout controller reloads page sections. |
Re: Where to place the common ajax functions for shipping module plugin
Can you please give me some sample url of how it should be for the controller function or some documentation link which is giving an example of how to write the controller for a new plugin/shipping method?
|
Re: Where to place the common ajax functions for shipping module plugin
Hello!
Please use the documentation at http://kb.x-cart.com/ for reference. The article on creating a new controller is here: http://kb.x-cart.com/display/XDD/Creating+new+page |
Re: Where to place the common ajax functions for shipping module plugin
Thanks! Got it working with the controller functions
|
All times are GMT -8. The time now is 01:09 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.