X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Ajax Requests (https://forum.x-cart.com/showthread.php?t=64961)

Cpt.Crashtastic 09-24-2012 12:51 PM

Ajax Requests
Is it possible to use the XCN Ajax handlers from our own code without extending what is there already?

I see when you drag an item to the cart it passes two specific paramaters, "cart" and "add" which I guess gets converted to doActionAdd() in CartAbstract.php

So if I wanted to call myFunction() in myControllerClass.php what parameters do I need to pass using the existing handlers?

Unless of course I'm barking up the wrong tree.

xplorer 09-25-2012 10:29 AM

Re: Ajax Requests
Yes, it is possible, but it depends on what you do.

You can't directly call a PHP method from JavaScript, but you can run an action in a controller class as follows:


  URLHandler.buildURL({target: 'example', action: 'test'}),
  function(XMLHttpRequest, textStatus, data, valid) {

This will run \Xlite\Controller\[current-area]\Example::doActionTest().

Please could you explain the desired behavior in details?

Cpt.Crashtastic 09-26-2012 08:02 AM

Re: Ajax Requests
That gave me enough info to do what I wanted.

It was for a button to attach an image to an order.

xplorer 10-02-2012 02:37 AM

Re: Ajax Requests
Here is a tutorial on working with AJAX requests:

All times are GMT -8. The time now is 06:37 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.