Skip to content

Instantly share code, notes, and snippets.

View markelog's full-sized avatar
😀
set your status

Oleg Gaidarenko markelog

😀
set your status
View GitHub Profile
@markelog
markelog / gist:42d43a489afb7201ddd6
Created September 28, 2014 12:17
More of jQuery.xhr
// See http://api.jquery.com/jQuery.ajax/#entry-examples
$.xhr( "some.php" )
.method( "POST" )
.send({ name: "John", location: "Boston" })
.then(function( xhr ) {
alert( "Data Saved:" + xhr.responseText );
});
$.xhr( "test.html" )
@markelog
markelog / gist:762c2584b53cace10fb3
Created August 27, 2014 13:38
jscs, js-file, context
file.iterateTokensByType("type", function() {
file === this // true
});
it('should not require between simple arguments', function() {
assert(checker.checkString('foo(a,b);').getErrorCount() === 2);
assert(checker.checkString('foo( a,b);').getErrorCount() === 1);
assert(checker.checkString('foo( a,b );').isEmpty());
});
it('should not require spaces for empty arguments list', function() {
assert(checker.checkString('foo();').isEmpty());
});
@markelog
markelog / gist:7407ac01a054cdbf0cc5
Created July 21, 2014 15:53
jQuery.xhr options
$.xhr( "url", {
method: "post",
timeout: 1000,
});
// Same as
$.xhr( "url" ).method( "post" ).timeout( 1000 )
// jQuery made popular chaining style in JavaScript,
// as i recall this approach we liked at San Diego meeting,
// i think we could use similar approach for $.xhr
//
// also https://github.com/visionmedia/superagent
$.xhr( "url" )
// Default method is GET
.method( "post" )