Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am not sure wether there is a serious problem or I am doing it wrong. I am using Laravel4 and Angularjs V1.2.5.

My code is simple and looks as follows:

Controller function:

public function userLogin(){


        // First we fetch the Request instance 
        $request = Request::instance();

        // Now we can get the content from it
        $content = $request->getContent();


        print_r($content);

    }

Angular code:

$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
    $scope.userLogin = function(event){

        event.preventDefault();
        var email = $scope.email;
        var password = $scope.password;
        var url = $location.absUrl()+'/userLogin/';
        var params = {'password': password, 'email': email};        
        var loginRequest = $http({ 
            method: 'POST',
            url: url,
            data: params
        });

        loginRequest.success(function(data){            
            console.log(data);
        });

        loginRequest.error(function(data){
            console.log(data);
        });
    };

But the response is always empty. I have tried many ideas but didn't work. The data is sent sucessfully but I am not able to read it on the server.

I tried the default Laravel methods like Input::all() OR Input:get() but none of the work.

Any help would be greately appreciated.

share|improve this question
    
Did you check you are actually sending password an email. You can inspect that with Chrome devtool network panel, and see the actually post request. –  pm.calabrese Dec 17 '13 at 14:27
    
Is the Laravel URL on the same domain? –  Atropo Dec 17 '13 at 15:09
    
Here is my "login" request to my Laravel 4 server : $http.post('/api/auth/login',JSON.stringify({'email':email, 'password':password})) It is Json, but Laravel doesn't make the difference using Input::get() –  Neozaru Dec 17 '13 at 17:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.