Below is the jquery ajax call I make to the controller
jQuery.post('index.php',{
'option' : 'com_test',
'controller': 'product',
'task' : 'loadColors',
'format' : 'raw',
'design_id' : design_id,
'collar_id' : collar_id
},function(result){
}).success(function(result) {
alert(result);
}).error(function() {
jQuery('div#color_wrapper h1').text('ERROR WHILE LOADING COLORS');
}).complete(function(result) {
alert(result);
});
In my controller there is a function as below.
function loadColors()
{
die;
}
My problem is even I have used die in the loadColors(), success and complete functions are being executed. What I want is a function which runs if we return something from loadColors() ? How can I get it done?
I personally would just check what the callback is and decide then what you would want to do.
for example.
If you really want not to let the success function run via the PHP script you should check on other headers to give back before you die. I’m not fully sure if that works since I haven’t used it before, but you can send headers that tell that there’s an error on the page.