Tech Rocks

Coldfusion
Java
JQuery

An online resource for latest web technologies like Coldfusion, JRun, Pro*C, JQuery, HTML5, PHP, W3C, Java, J2EE, C, C++, ORACLE, PL/SQL, MySql, Ajax, Coldbox, Fusebox, UNIX, JavaScript, NodeJS and much more...

Sunday, April 10, 2011

CFC Documentation

For using the cfc explorer use the following link on the web server:

http://hostname.com/CFIDE/componentutils/cfcexplorer.cfc?method=methodname&name=cfc.path.cfcname&path=/cfc/path/cfcname.cfc

asks for RDS credentials.

Submiting a form using jquery ajax

Example:

function postit_7(obj) {
    var recurring_transaction = $("#recurring_transaction").val();
    var isrecurring = true;
       
    
    
    var url = ajaxInterface;
    url = url + '?fn=1&' + (new Date()).getTime();
   
    id = "step3_container_1";
    showpreloader(id);
   
   
    obj.ajax({            
        type: 'POST',
        url: url,
        data: $('#payForm').serialize(),
        success: function(data, status) {
            //alert(data);
            var content = obj.parseJSON(data);
            var test = content["key"];
           
            var ERROR_CODE = content["ERROR_CODE"];
            var RESPONSE_MESSAGE = content["RESPONSE_MESSAGE"];
           
            $('#id_transaction', window.parent.document).val(test);
           
            if(ERROR_CODE != 0)
                completedtransaction_2_1(ERROR_CODE,RESPONSE_MESSAGE);
            else
                completedtransaction();
        },
        error: function(e){
            alert("postit_4() function error: "+e.statusText);
        },
        complete: function(){
       
        }
        ,cache: false
    });
}

Checkbox validation using jquery

Example:

function validate_1(val){
    var msg = "";
    var chk  = false;
    if(val == 6) {
        $("[name='zzz']").each(function() { 
            //alert($(this).is(':checked'));
            if($(this).is(':checked')) chk = true;   
        });
        if(!chk) msg = msg + "zzz is required\n";
    }
    if(val == 7) {
        $("[name='zzz']").each(function() { 
            //alert($(this).is(':checked'));
            if($(this).is(':checked')) chk = true;   
        });
        if(!chk) msg = msg + "zzz is required\n";
    }
    if(msg != ""){
        alert(msg);
        return false;
    } else {
        return true;
    }
}

Email RegExp

Example:

function checkEmail(str)
{
    var x = str;
    var filter = /^(['a-zA-Z0-9_\.\-\\])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(x)) return true;
    return false;
}

Saturday, April 9, 2011

Ajax Post with JSON returned

Example:
function postit_3(obj) {
       
    signin_obj = null;
    url = url + '?' + (new Date()).getTime();
    username = obj("#username").val();
    password = obj("#password").val();
   
    id = "step2_container";
    showpreloader(id);
   
    obj.ajax({            
        type: 'POST',
        url: url,
        data: {returnFormat: 'json', user: username, password: password},                
        success: function(json, status) {
            //alert(json);
            var period = $("#hid_period").val();
            var productcd = $("#hid_productcd").val();
            var content = obj.parseJSON(json);
            obj.each(content, function (e) {
                if(e === "COLUMNS" && this[0] == "ERROR") {
                    $('#step2_container').load(load_url_1, function(){ alert("LOGIN ERROR!"); });
                }
                else
                if(e === "DATA")
                for(i=0; i< this.length; i++){
                   
                    //alert("RECORD: " + this[i]);
                    signin_obj = this[i];
                   
                   
                    if(signin_obj[37] >= 0) {
                        Expired = true;
                    }
                    else {
                        Expired = false;
                    }
                   
                   
                    //check additional members logic and insert leads..
                    if(signin_obj[32] == 'A') { redirect_1(); return;}
                    //check monthly sub
                    //postit_6_2(obj); Not needed any more
                    if(signin_obj[32] == 'MO') {redirect_1(); return;}
                    if(signin_obj[32] == 'MO') hideyearlymonthlytabs();
                        
                                        postit_6(obj);
                    
                                    }
            });
        },
        error: function(e){
            alert("postit() function error: "+e.statusText);
        },
        complete: function(){ /*alert("AJAX COMPLETE");*/ }
        ,cache: false
    });
}

JQuery Ajax Post

Example:
function postit_1(obj) {
   
    var email = obj("#email").val();
    var url = baseurl + '/forgotPassword.cfm';
    url = url + '?' + (new Date()).getTime();
    showpreloader("forgotmsg");
    obj.ajax({            
        type: 'POST',
        url: url,
        data: {returnFormat: 'plain', email: email},                
        success: function(data, status) {
                //alert(data);
                obj("#forgotmsg").html(data);
        },
        error: function(e){
            alert("postit_1() function error: "+e.statusText);
        },
        complete: function(){}
        ,cache: false
    });
}