Link to home
Start Free TrialLog in
Avatar of Abhay Kalariya
Abhay KalariyaFlag for India

asked on

Getting problem with http post method in angularJS to classic asp

Hi
I am new in angularJS.
i am working with classic asp and angularJS.
when i call http post method to classic asp page in angularJS  its send data to classic asp page. but when i am try to retrieve posted data on classic asp page i found nothing?

is there i am doing wrong?

here is my code sample

----------Html code---------------
<div ng-app="CallSiteVisitor" ng-controller="SessionAndVisitor">
<form ng-submit="SaveData()" >
<input type="text" ng-model="form.firstname">
<input type="text" ng-model="form.lastname">
<input type="submit">
</form>
</div>
---------Html code end----------

-----------Controller code ------------
var app = angular.module('CallSiteVisitor', ['fm']);
      app.controller('SessionAndVisitor', function($scope, $http) {

$scope.form = {};
        $scope.SaveData = function() {
                  $http({
                    method  : 'POST',
                    url     : 'http://www.xyz.com/action_contactformAJ.asp',
                    data    : $scope.form,
                    headers : { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }
                   })
                    .success(function(data) {
                        if (data.errors) {
                                        // error code
                        } else {
                         // data code
                        }
                    });
                  };
      });
-----------Controller  code end---------


---------- Classic asp page code (action_contactformAJ.asp)-------------------------
<%
Response.write request("FirstName") & "  " & request("LastName")
' here i found null value but when i see in browser by pressing f12 key in network mode its shown that when post method call its send data with text box values but on other side i found nothing.... is there i am doing some wrong things?


%>
---------- Classic asp page code end------------------------


please advice

thanks
Abhay
Avatar of Manju
Manju
Flag of India image

In classic asp, for post method, we use request.form("FirstName").

Try response.write request.form("FirstName")

and also in html, change the below

<input type="text" ng-model="form.firstname">

to

<input type="text" name = "FirstName" ng-model="form.firstname">
Avatar of Abhay Kalariya

ASKER

Hi Manju,

first of all thanks for your prompt replay.

As you suggest i have change request("FirstName") to Request.Form("FirstName")

and also change html ( added name attribute in text element )

but still i am not retrieving value of text element (Firstname and Lastname)  in another page.
try this in classic asp -

response.write request.form("form.firstname")
I try it but still i getting null value as firstname.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.