What do you get is you go to
http://localhost:3000/users?callback=JSON_CALLBACK in your browser?

Adrian

On 30 October 2014 21:09, Adham El-Deeb <[email protected]> wrote:

> I'm using **ruby on rails** for api and **angularjs** for client side.
> I generated the **angular** app using **yeoman**
> I'm trying to GET user data from the api using this code:
>
>     angular.module('clientApp')
>       .controller('UserCtrl', function ($scope, $http) {
>       $http.jsonp('
> http://localhost:3000/users?callback=JSON_CALLBACK').success(function
> (data) {
>       console.log(data);
>       })
>       });
>
> and i have this error on my **browser console**
>
>     Refused to execute script from '
> http://localhost:3000/users?callback=angular.callbacks._0' because its
> MIME type ('application/json') is not executable, and strict MIME type
> checking is enabled.
>
> and this is the api side code for GET this data:
>
>       def index
>         if params[:callback]
>           render json: {data: {:users => User.all.to_json}, :callback =>
> params[:callback] }
>           # format.js { render :json => {:users => Users.all.to_json},
> :callback => params[:callback] }
>         else
>           render json: User.all
>         end
>         # render json: User.all.paginate(:page => params[:p], :limit =>
> params[:per])
>       end
>
> --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to