Using jMaki With PHP on OpenSolaris

1 2 Page 2
Page 2 of 2
    // uncomment to turn on the logger
    jmaki.debug = false;
    // uncomment to show publish/subscribe messages
    jmaki.debugGlue = false;

    // map topic for the add Product button
    jmaki.subscribe("/yahoo/button/onClick", function(args) {
    // get the values of the 3 fields in the form:
    var name= document.getElementById("name").value;
    var category= document.getElementById("category").value;
    var price= document.getElementById("price").value;
    //do an ajax request to the add server side logic, with the correct params:
    jmaki.doAjax({
    url : "add.php", // call the add.php URL
    method : "POST",
    content : {
    name : name,
    category : category,
    price : price
    },
    callback: function(req) {

    //in this call back, we just add a new row to the local jMaki table
    if (jmaki.trim(req.responseText) == "value added")
    jmaki.publish ('/yahoo/dataTable/addRow',
    {
    value: {
    name : name,
    category : category,
    price : price
    }
    }
    );
    else
    alert ("error adding a row: "+req.responseText);
    }
    });
    });

Summary

By adding the jMaki Ajax framework to the fully integrated software stack provided by OpenSolaris 2008.05, which includes a PHP engine, an Apache Web Server, and a MySQL database, you can develop web applications that present modern Web 2.0 type behavior, combining the power of a scalable operating system and the rich capabilities of Ajax technologies. The jMaki framework hides the complexity of JavaScript and server-side PHP page rendering.

Further Reading

About the Author

Ludovic Champenois (ludo) is a principal engineer at Sun Microsystems. He is currently an architect for the Java EE GlassFish Application and the OpenSolaris WebStack (AMP), focused on developer experience and tools integration.

This story, "Using jMaki With PHP on OpenSolaris" was originally published by JavaWorld.

Related:

Copyright © 2008 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2