Web Info & Tutorials

October 2nd, 2007

AJAXIAN FEATURED TUTORIAL: PARSE JSON WITH JQUERY AND JAVASCRIPT

Last week, we posted a tutorial by Brian Reindel which showed how to parse XML with jQuery. The feedback was pretty good but many readers felt that JSON is the data packet format of choice and an XML-focused tutorial wasn’t their cup of tea. Brian promised a follow-up tutorial focusing on JSON and he has delivered.

In his tutorial, Parse JSON with jQuery and JavaScript, Brian takes you step-by-step through the process of retrieving and parsing a JSON packet:

Getting JSON using jQuery is extremely straightforward. Just like $.ajax(), there is a $.getJSON() method, with a call to a file, and a function to pass the data through for parsing. The common $.each() method in jQuery can be used to traverse the “nodes” (keys) that you indicate. You could just as easily use your own for loop.

As usual, Brian includes plenty of code examples to further reinforce his techniques and provides a source code download for you to review.

You can catch both tutorials here:

jQuery and XML revisited
Parse JSON with jQuery and JavaScript

October 2nd, 2007

PERSISTENT OBJECTS WITH PERSEVERE THE CLIENT AND JSPONIC THE SERVER

Kris Zyp has made a charge in the persistent JavaScript space by releasing both a client and a server to handle JSON persistence.

Persevere s an open source persistent object mapping framework for JavaScript in the browser. Persevere allows programmers to access, traverse, and manipulate persisted data easily with standard JavaScript syntax and intuitive Persistent JavaScript (PJS). Persevere implements the PJS API and maps JavaScript objects to persistent storage objects remotely through JSON based RESTful web services following the JSPON (JavaScript Persistent Object Notation) data interchange specification. Persevere accesses persisted object graphs provided through JSPON data sources which can represent various underlying sources such as database tables and can even span domains. Persevere can provide orthogonal persistence and lazy loading support with standard JavaScript property access and modification through JavaScript optional pre-processing, such that persisted data can be modified with plain JavaScript, for example:

JAVASCRIPT:
  1.  
  2. var result = pjs.load("data or query id"); // load a object mapped to
  3. persistent data
  4. var object = result[1]; // access items from a result
  5. var value = object.prop; // lazy loading is performed when necessary
  6. object.prop = "new value"; // change a property and it is automatically sent
  7. to the server to be persisted
  8. result.push({name:"new object/row"}) // adding and removing rows/objects
  9. from persisted data can be done with normal JS array methods
  10. Array.remove(result,object); // or splice
  11.  

Persevere can also be used without preprocessing, or it can provide these
capabilities natively with JavaScript 1.7. Persevere allows supports
application code to be persisted and exist within these object graphs, to
facilitate a unique "live programming" approach to object oriented design
and organization.

Jsponic provides a server implementation of the JSPON protocol, and therefore is ideal as a backend for Persevere (or any other JSPON client). Jsponic is a Java-based server that implements the JSPON protocol for exposing persistent data storage as RESTful JSON web services, and with full capabilities for modification of persisted data, execution of remote/distributed JavaScript methods, and data centric object level security. Jsponic includes an internal dynamic object database, and supports standard SQL tables, XML files, and web service, and exposes these data sources through JSON. Jsponic also implements the PJS specification, and provides persistent object mapping in a server local JavaScript environment (Rhino) which facilitates distributed remote calls between the client and server with both environments referencing and sharing access to the same persisted data.

Persevere and Jsponic can be used independently of each other, as communication is based completely on JSON (JSPON and JSON-RPC), and it is easy to implement these publicly available specifications to write your own client to connect to Jsponic or build your web service as a backend to Persevere. Persevere and Jsponic both come with the JSPON Object Browser to facilitate testing, accessing, and manipulating JSPON data to simplify building your own client or server.

October 2nd, 2007

DOJO GFX GAME USING SVG/VML RENDERING

Paolo Ardoino has created a fun little web game called Be Quick Or Be Dead:

Game rendering is very simple:

  • ctx = dojox.gfx.createSurface creates 2D drawing surface
  • images, text, rectangles, … are all shapes that can be created on that surface (i.e. img = ctx.createImage(); )
  • shapes could be modified with setShape method (i.e. img.setShape(newShape); )

I hope you will enjoy Be Quick Or Be Dead, because I’m planning to code a multiplayer version :D

Be Quick Or Be Dead

October 2nd, 2007

ADOBE UPDATES SPRY AJAX/JS FRAMEWORK

Adobe free edition 1.6 of their Spry Javascript/Ajax/Effects framework. The bounteous pore for this promulgation was deference with scheme standards, making bounteous changes to encourage unobtrusiveness and proportional enhancement:

As I mentioned in my preceding post, this promulgation is most upbringing our mettlesome with respects to scheme standards, availableness and proportional enhancement, among another topics. We wrote a ordered of articles discussing these topics. You crapper analyse them discover at http://labs.adobe.com/technologies/spry/articles/best_practices/.

In addition, the Spry aggroup spruced up their switch crossing aptitude with the launching of the Element Selector utility:

Ah, the course Element Selector. Along the lines of jQuery and DOMQuery, the Element Selector (SpryDOMUtils.js) is a programme utilised for grabbing binary parts of the tender using CSS Selectors and applying functions to them. Our pace is on par with another tools and we hit burly and faithful CSS3 support. Read most it here and analyse it discover here.

Finally, the aggroup has created a Spry Updated for Dreamweaver CS3 which module wage comprehensive hold for the Spry support within Adobe’s application product. This spreading crapper be download via the Adobe Labs site.

You crapper download Spry v1.6 from here.