I am having a ajax call to cakephp function in controller. After the controller function returns the response, the complete/success/error nothing is called. Any help will be greatly appreciated.
JS code:
function processLeadSecond(data){
        Pace.track(function(){
            jQuery.ajax({
                url: '/OnePage/processLead',
                data: data,
                method:'post',
                headers:{
                    'x-keyStone-nonce': nonce
                },
                complete: function(xhr, str){
                    var status = xhr.responseJSON.status;
                    var redirect = xhr.responseJSON.redirect;
                    var total_sold = xhr.responseJSON.total_sold;
                    var AppType = xhr.responseJSON.AppType;
                    if(status == 'Success'){
                        if(redirect !='' &&  total_sold != 0){
                            window.location.replace(decodeURIComponent(redirect));
                        }else{
                            window.location.replace('/OnePage/thankyou');
                        }
                        return false;
                    } else{
                        window.location.replace('/OnePage/fault');
                    }
                }
            });
        });
    }
Cake PHP Code:
$socket = new HttpSocket(array('timeout'=>180));
                $response = $socket->post($url,$lead_data_json,$config);
                $status_json = json_decode($response);
                //echo "status_json :: ";print_r($status_json);
                $response_array = array();
                $response_array['status'] =$status_json->status;
                $response_array['redirect'] = $status_json->redirect;
                $response_array['total_sold'] = $status_json->total_sold;
                $this->Session->write('Application.lead_id', $status_json->lead_id);
                if($status_json->total_sold == 0){
                    if($this->Session->read('Application.LoanAmount1')==""){
                        $this->Session->write('Application.LoanAmount1', $s_data['LoanAmount']);
                    }
                }
                $response_array['AppType'] = $this->Session->read('Application.AppType');
                return json_encode($response_array);
The response is as follows:
{ status: Success, redirect: https://cmportal.leadspediatrack.com/lead-redirect.do?token=2747cd0d408c2c872e089cc117e7ba86, total_sold: 1, AppType:personalloan }
 
    