I am debugging some stuff on a client’s site that has a module developed by someone else. It’s not working correctly.
I have a simple Ajax call to a controller:
jQuery.ajax({
url : "http://www.site.com/quickview/index/cart",
complete : function(data){
// data.responseText is empty here.
jQuery('span.topLinks').replaceWith(data.responseText);
// This returns the data object with statusText = "error"
console.log(data);
}
})
Which calls a simple action in the controller:
public function cartAction()
{
// This log call never fires
Mage::log('foobar',null,'temp.log');
$this->loadLayout();
$Top = $this->getLayout()->getBlock('top.links')->toHtml();
$this->getResponse()->setBody($Top);
}
The problem is that the Ajax call never makes it to the controller. I have placed a Mage::log call inside the cartAction(), but it never gets fired.
The controller is indeed set up properly, as I can browse directly to cartAction() which will render the block I am attempting to return back to the Ajax call (if I echo it, it’s not echoed here).
If I place inside the Ajax call:
console.log(data);
It returns the object with statusText: “error”.
I have tried every permutation of the Ajax URL that I can think of, absolute, relative, with index.php, without index.php, etc. Every time, data.responseText is just an empty string.
Any thoughts?
This was finally resolved. The module also had a controller set up for Adminhtml that used the same frontname so browsing to the controller action directly worked, but when called through the template file via Ajax, it didn’t like the http to https switch.
Assigned a different frontname to the admin controller and things are fine.