Skip to content

Instantly share code, notes, and snippets.

@wittawasw
Created September 24, 2014 17:48
Show Gist options
  • Save wittawasw/4cde7fb41e40f1d290db to your computer and use it in GitHub Desktop.
Save wittawasw/4cde7fb41e40f1d290db to your computer and use it in GitHub Desktop.
Rails jsonp request with angular
class HomeController < ApplicationController
def testtest
puts '########################################'
response = params[:test]
render :json => response.to_json, :callback => params['callback']
end
end
$http.jsonp('/testtest?callback=JSON_CALLBACK&test=hello').
success(function(data, status, headers, config) {
//what do I do here?
alert(data);
}).
error(function(data, status, headers, config) {
alert(status);
// $scope.error = true;
});
Myapp::Application.routes.draw do
get 'testtest' => 'home#testtest'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment