Error sending json via $http

Asked

Viewed 91 times

0

I am trying to send a json via $http.get, but it is returning an error in the console "500 (Internal Server Error)" system.technology.Ws/pedidGravar.Asp:1 Is this error in ASP system or $http request? Follow the requisition code

    $http({
       method: 'GET',
       url: 'http://sistema.tecnologia.ws/pedidoGravar.asp',
       data: JSON.stringify($scope.recuperaSeuPedido),
       headers: {'Content-Type': 'application/json'}
     }).then(function successCallback(response) {
         console.log(response.data)
         console.log("enviou");
       }, function errorCallback(response) {
         console.log(response.data)
         console.log("nao enviou");
       });

I disabled $http and did it in pure js and returns the same error. Follow the code below

   xhr = new XMLHttpRequest();
     var url = "http://sistema.tecnologia.ws/pedidoGravar.asp";
     xhr.open("GET", url, true);
     xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
     xhr.onreadystatechange = function () {
         if (xhr.readyState == 4 && xhr.status == 200) {
             console.log(xhr.responseText);
         }
         console.log(xhr.responseText);
     }
     xhr.send("json=" + encodeURIComponent(JSON.stringify($scope.recuperaSeuPedido)));
  • I don’t know Angular.js or have the slightest idea what "Ionic" is, but...the method shouldn’t be POST ?

  • already tried tbm, but returns the same error

  • The error is in the *.Asp file or on your server. If you display the request codeGram.Asp will look better to help.Asp.

  • Your server supports ASP?

  • Yes yes...ja corrected the error...vo post the code to help the guys who need tbm

1 answer

0

It was information error. Vo post the code here, to help the guys who have the same problem

    $http({
     //Method alterado
     method:'POST',
     url:'http://sistema.tecnologia.ws/pedidoGravar.asp',
     //Data alterado
     data: "json=" + encodeURIComponent(JSON.stringify($scope.recuperaSeuPedido)),
     //Headers alterado
     headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
  })
  .then(function successCallback(response){
        console.log(response.data)
        console.log("enviou");
  }),
  function errorCallback(response){
     console.log(response.data)
     console.log("nao enviou");
  }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.