Object Oriented Javascript : ECMA Script 5 : Summary


JavaScript is famous for being the world’s most misunderstood programming language. JavaScript is now used by an incredible number of high-profile applications, showing that deeper knowledge of this technology is an important skill for any web or mobile developer.

Unlike most programming languages, the JavaScript language has no concept of input or output. It is designed to run as a scripting language in a host environment, and it is up to the host environment to provide mechanisms for communicating with the outside world.

The most common host environment is the browser, but JavaScript interpreters can also be found in a huge list of other places, including Adobe Acrobat, Adobe Photoshop, SVG images, Yahoo’s Widget engine, server-side environments such as Node.js, NoSQL databases like the open source Apache CouchDB, embedded computers, complete desktop environments like GNOME (one of the most popular GUIs for GNU/Linux operating systems), and others. Continue reading

Reporting in Rails : Report generation : Downloadable in any Format | PDF | CSV | XLS

Working on report generation is a time consuming task yet very necessary for any software projects. End of the day every business owner needs to see where their business stands or see ongoing activity in the system. Reports need list of records and Graphs/Charts to show the big-picture at a glance.

 With Rails Admin

If you are using RailsAdmin for managing you web-application from backend, you get reports for your data out of the box. In addition you can edit/update in no time with ease. You will not have charts and graph at that instant though.

How can I get Charts?

Continue reading

Javascript : jQuery : How to merge two json obects or Hashes in JS?


hashOne = {
  first_elm: 'I am first',
  second_elm: 'I am sec'
hashTwo = {
  third_elm: 'I am third',
  fourth_elm: 'I am fourth'

we cannot simply append the second to the first like

var newHash = hashOne + hashTwo
>> "[object Object][object Object]"

However, jQuery has a helper method to merge two hashes..


newHash = $.extend({}, hashOne, hashTwo);
>> Object {first_elm: "I am first", second_elm: "I am sec", third_elm: "I am third", fourth_elm: "I am fourth"}


If you do as following

newHash = $.extend(hashOne, hashTwo);

you will have the `hashOne` modified

> hashOne
> Object {first_elm: "I am first", second_elm: "I am sec", third_elm: "I am third", fourth_elm: "I am fourth"}

jQuery :: AJAX request return 200 OK but error event is fired instead of success

  • The main thing is, if data is not properly formatted in expected format
    such as JSON then parse_error is triggered. So your success block is not 
    In fact null should also be wrapper properly in {}
  • dataType (default: Intelligent Guess (xml, json, script, or html))
    Type: String
    The type of data that you’re expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string).
  • "json": Evaluates the response as JSON and returns a JavaScript object.
  • The JSON data is parsed in a strict manner;
  • any malformed JSON is rejected and a parse error is thrown
  • error
    Type: Function( jqXHR jqXHR, String textStatus, String errorThrown )
    A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as “Not Found” or “Internal Server Error.” As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event.