/**
 * Copyright Xenario GmbH, 2009, Hannover, Germany
 * @author: Christian Rößler (roessler@xenario.de)
 * @file: xenjquery_ajaxcontent.js
 * @description: provides a function tha sits on top of jquery and provides a ezPublish-content-replace-ajax-style-method... sort of.
 *
 */

/**
 * load the content of a node without the surrounding pagelayouot via ajax and put the result into the applied target-div-container
 */
function xen_ajaxcontent(nodeId, targetContainerId)
{
    //nodeId and targetContainerId must be given! nodeId must be a valid integer
    // ...
    
    // create a ajax-request to /ajaxcontent/load/nodeId  and fetch the output
    var res = $.ajax({
	    global: false,
	    type: "GET",
	    //data: {nodeId:nodeId},
	    dataType: "html",
	    url: "/ajaxcontent/load/" + nodeId,
	    beforeSend: function(){
	        // ...
	    },
	    complete: function(){
	        // ...
	    },
	    error: function (XMLHttpRequest, textStatus, errorThrown){
		    // typically only one of textStatus or errorThrown  will have info
		    alert(textStatus+':'+errorThrown + res);
	    },
	    success: function(html){
            // place the result from the module-call into the given targetContainer
            $('#'+targetContainerId).html(html);
	    }
    });
    return false;
}

