简体   繁体   中英

Joomla 3.2, get works, post doesn't

So I have this JS code:

myClass = new Class({
  initialize: function() {
    this.btnSubmit = document.id('btnSubmit');
    this.sendData = new Request({
      "url":"/",
      "method":"post",
      "data": {"option":"com_my4quiz", "controller":"conduit", "task":"save", "hrdata":"foo"},
      "onSuccess": this.handleResult.bind(this)
    });

    this.btnSubmitObserver = function() { this.sendData.send(); }.bind(this);
    this.btnSubmit.addEvent("click", this.btnSubmitObserver);
  },

  handleResult: function(stuff) {
    //do stuff
  }
});

If I'm posting this to my Joomla 3.2.0 component it returns the home page. As soon as I switch to get, it sends the data to the correct place and I get what I expect.

I think its due to your controller page loads the entire view.

This may happen due to inside your controller save() . function not rendering any specific view .

So the solution is after the Ajax result just render the proper layout or just put an exit();

At the end of your save()

exit();

or

$view->setLayout($layoutName);
$view->display();

Hope its helps..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM