Skip to content Skip to sidebar Skip to footer

Return Json Object Fron Function

I am trying to return a json object from a function and use it as the below code, but it's not working. what wrong with it? var x = [ 'EditFileName' , 'dosometing' ]; c_loadAjax.ap

Solution 1:

Try with the return keyword

var x = [ "EditFileName" , "dosometing" ];
c_loadAjax.apply(this,x).done(function(json){
    alert(json.error);
});
function c_loadAjax( post , option ){
    return $.ajax({
        type:"POST",
        url:"/includes/Ajax.php",
        data:{post:post,option:option},
        error:function(result){
            return '{"error":"Error"}';
        },
        success:function(result){
            return jQuery.parseJSON(result);
        }
    });
}

Post a Comment for "Return Json Object Fron Function"