Created
September 24, 2014 17:48
-
-
Save wittawasw/4cde7fb41e40f1d290db to your computer and use it in GitHub Desktop.
Rails jsonp request with angular
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeController < ApplicationController | |
def testtest | |
puts '########################################' | |
response = params[:test] | |
render :json => response.to_json, :callback => params['callback'] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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; | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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