Please create a plunkr that exhibits your problem so we can better help you.



On Fri, Feb 21, 2014 at 5:11 AM, Ivan Bernabucci <[email protected]>wrote:

> Hello, I read about this issue many times but i couldn't get any results
> even following the suggestions around. I have problems with an application
> I'm working on that should connect to the API of a remote server.
>
> The GET request I make to the server from Chrome and Firefox (and Fiddler)
> works perfectly and it gives me back the expected JSON packet
>
> In Angular I tried both:  (sorry I couldn't find a system to format the
> code)
>
> $http({
>      url:urlAddress,
>      method:"GET",
>      data: {user: 'xxx', pass: 'xxx', request: 'xxx', key: $scope.query,
> loc_types: 'xxx'}
>  }).success(function(data) {
>   console.log('done');
>  $scope.jex= [];
> for (var i = 0; i < data.length; i++) {
>          $scope.jex.push(data[i]);
>  };
> }).error(function(r,t,et){
>        console.log(r);
>  console.log(t);
>        console.log(et);
> });
>
> and
>
> *$http({
>   url: requestTo,
>   method: "JSONP"
>        }).success(function(data) {
> console.log(data);
> $scope.jex= [];
> for (var i = 0; i < data.length; i++) {
>  $scope.jex.push(data[i]);
> };
>        }).error(function(r,t,et){
>      console.log(r);
>     console.log(t);
>     console.log(et);
>  });
>
> In the beginning of my js file I set
>
> myApp.config(['$httpProvider', function($httpProvider) {
>  $httpProvider.defaults.useXDomain = true;
>         delete $httpProvider.defaults.headers.common['X-Requested-With'];
>
>     }
> ]);
>
> The version with GET gives me back an XMLHtppRequest  - No
> Access-Control-Allow-Origin error.
>
> The version with JSONP (for wich in the provided URL I added at the end
> '&callback=JSON_CALLBACK') it gives me back the error' Resource
> interpreted as Script but transferred with MIME type text/plain'
>
> In this last case when I check Firebug or Chrome Tools, the Response tag
> shows me the JSON packet sent by the remote server but the console hit the
> error callback of the http method.
>
> This behavior happens both on my localhost when I try to reach the server
> and on a remote server where i make tests.
>
> I don't know what to try anymore. Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to