tags:

views:

100

answers:

1

Hi,

i have created a simple HTML with XML as response. That was worked perfect in simple condition. but while i tried to use the Ajax function to retrieve the response, it returns nothing (no alerts get called). I pasted my code down. please look into that and please help me out this. thanks.

Code :

    jQuery("#list").jqGrid({
        //url:'example.xml',
        datatype: function () {
            $.ajax({
                url: 'example.xml',
                type: 'POST',
                dataType: 'xml',
                timeout: 1000,
                error: function(){
                    alert('Error loading XML document');
                },
                success: function(xml){
                   alert("*********** comin here ********");
                    // do something with xml
                }
        },
            });
        colNames:['QueueName','SLA Associated', 'SLA met', 'SLA Breached', 'SLA MET %', 'SLA Breached %'],
        colModel :[ 
            {name:'QueueName',index:'QueueName', width:150}, 
            {name:'SLAAssociated',index:'SLAAssociated', width:150}, 
            {name:'SLAmet',index:'SLAmet', width:150}, 
            {name:'SLABreached',index:'SLABreached', width:150}, 
            {name:'SLAMETPer',index:'SLAMETPer', width:150},
            {name:'SLABreachedPer',index:'SLABreachedPer', width:150}
        ],
        pager: jQuery('#pager1'),
        rowNum:1,
        rowList:[5,10],
        imgpath: 'themes/basic/images'
    });     
}); 

example.xml :

1 1 1 cellcontent notes notes notes notes notes

A: 

Instead of success and the following codeblock:

success: function(xml){
               alert("*********** comin here ********");
                // do something with xml
            }

You should use the complete option, such as below:

complete: function(xmldata, stat) {
    if (stat == "success") {
        alert("your code goes here...");
    }
}
Justin Ethier