1

i using $http post After success i get the headers in network and it consist of the General,Request Headers,Response Headers,Form Data.

if i using headers() i got response headers but how i get the form data object.

 $http({
        method: "POST",
        url: "http://localhost/demoPaymentGatway/index.html",
        headers: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        'X-Requested-With': 'XMLHttpRequest'
                    }
                }).success(function(data, status, headers, config) {
                    console.log(headers());
                    console.log();
                    }).error(function(r4) {
                        console.log(headers);

                });

Headers:

General:

 Request URL:http://localhost/demoPaymentGatway/index.html
 Request Method:POST
 Status Code:200 OK
 Remote Address:[::1]:80

Response Headers: 

 Accept-Ranges:bytes
 Connection:Keep-Alive
 Content-Length:1856
 Content-Type:text/html
 Date:Sat, 06 Aug 2016 12:17:17 GMT
 ETag:"740-5396528fb715b"
 Keep-Alive:timeout=5, max=100
 Last-Modified:Sat, 06 Aug 2016 11:05:25 GMT
 Server:Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.5.37


 Request Headers:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:700
Content-Type:application/x-www-form-urlencoded
Cookie:PHPSESSID=el7a4qk56sv4ujo4kou0qf43k4
Host:localhost
Origin:null
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,  like Gecko) Chrome/52.0.2743.82 Safari/537.36

Form Data:
mihpayid:114256656
mode:
status:failure
unmappedstatus:userCancelled
key:WHlKGc
txnid:264997125205
amount:1.0
addedon:2016-08-06 17:47:58
productinfo:productitem
firstname:vasu

please help me how to get this form data using $http,$resource

3
  • Do I understand you correctly, you basically want to get the form data and manipulate it before the requst is actually made, or do you want it in the success call back itself ? Commented Aug 6, 2016 at 12:51
  • yes i want to get form data.but form data come from the redirecting url from the payment gateway. Based on success/ failure i want fire the order. Commented Aug 6, 2016 at 12:57
  • please tell me how to get this only formdata... Commented Aug 6, 2016 at 12:59

1 Answer 1

0

If you need to access the form data that was sent in the POST request in the success call back you need to look into the config.data property .

$http({
        method: "POST",
        url: "http://localhost/demoPaymentGatway/index.html",
        headers: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        'X-Requested-With': 'XMLHttpRequest'
                    }
                }).success(function(data, status, headers, config) {
                    //This is the post data that was originally sent
                    console.log(config.data);
                    }).error(function(r4) {
                        console.log(headers);

                });

For reference please see this link

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

4 Comments

sorry dude. I got the undeined.
config is for requested object.
After redirecting from the payment gateway. the payment gateway post the data to this localhost/demoPaymentGatway/index.html that is headers.
yes correct config is the object that you set when you send the request. However the config object in the success call-back does contain the original data you sent.... or perhaps I did not understand your query in the first place... we could move this to chat

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.