2

I am new to AngularJS. I am trying to POST data to call.php page from AngularJS page. My code for that is:

var request=$http({
                    url: "call.php",
                    method: "POST",
                    data: { uid: uname,upass: upass }
                });

But on call.php page it says undefined index:uid.I want this uid and pass on call.php page and according to that I will search database row. Please help me, Where I am wrong? Thanx in advance.

6
  • Could you please provide a fiddle for your snippet Commented Aug 11, 2015 at 6:44
  • Don't think you need the method part. Your api should know when it hits. I could be wrong though. I never put it in for my get requests. Commented Aug 11, 2015 at 6:53
  • URL for fiddle is: jsfiddle.net/ak21/3zujtuop/1 Commented Aug 11, 2015 at 6:53
  • Don't Use JQuery inside of angular controller, use $scope instead of JQuery selectors Commented Aug 11, 2015 at 7:07
  • I have tried using $scope.uname to get the value but its not working Commented Aug 11, 2015 at 7:14

1 Answer 1

1

As described in official documentation use $http.post('/target/url', optionalDataInRequestBody, params: { param1: 'value1', param:2: 'value2'}), post sends data as request body but it looks like you want to acces them as query params.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.