opal/opal-jquery/http.rb in opal-jquery-0.0.11 vs opal/opal-jquery/http.rb in opal-jquery-0.0.12
- old
+ new
@@ -1,11 +1,7 @@
-# Wraps jQuery's ajax request into a ruby class.
-#
-# HTTP.get("/users/1.json") do |response|
-# puts "Got response!"
-# end
-#
+require 'json'
+
class HTTP
attr_reader :body, :error_message, :method, :status_code, :url, :xhr
def self.get(url, opts={}, &block)
self.new(url, :GET, opts, block).send!
@@ -38,10 +34,10 @@
%x{
if (typeof(payload) === 'string') {
settings.data = payload;
}
- else if (payload != null) {
+ else if (payload != nil) {
settings.data = payload.$to_json();
settings.contentType = 'application/json';
}
settings.url = url;