tags:

views:

426

answers:

2

Hi,

JQGrid datatype as Ajax function not getting called. once i tried to debug using firebug, found out that those lines are not exectuced. please let me know the issue with my code. Thanks in advance.

jQuery("#list").jqGrid({
        //url:'example.xml',

            datatype: function() {
                $.ajax({
                    url: "example.xml",
                    data: "{}",  
                    dataType: "xml",
                    mtype: "GET",
                    complete: function(jsondata, stat) { alert((jsondata.responseText));
                        if (stat == "success") {
                        alert("ew");
                        }
                    },
                    error : function () {alert("error")}
                });
            },
        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'
    });     

in Header i add as follows

<html xmlns="http://www.w3.org/1999/xhtml"&gt;

<link rel="stylesheet" type="text/css" media="screen" href="themes/basic/grid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="themes/jqModal.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/report.css" />
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.jqGrid.js" type="text/javascript"></script>
<script src="js/jqModal.js" type="text/javascript"></script>
<script src="js/jqDnR.js" type="text/javascript"></script>
A: 

your function needs to take in the postdata as a parameter

datatype: function(postData) {
                $.ajax({
                    url: "example.xml",
                    data: postData,  
                    dataType: "xml",
                    mtype: "GET",
                    complete: function(jsondata, stat) { alert((jsondata.responseText));
                        if (stat == "success") {
                        alert("ew");
                        }
                    },
                    error : function () {alert("error")}
                });
            },
Paul Creasey
Thanks for your response. But its not working but still :(
Manikandan
I have tried to give the relative path for the url. but still issues occur. please help me to get out of this issue.
Manikandan
why double brackets here `alert((jsondata.responseText));`?and your missing a semi colon here `error : function () {alert("error")}`
Paul Creasey
Please look the below snippet. still the function not get executed.datatype: function(postData) { $.ajax({ url: "example.xml", data: postData, dataType: "xml", mtype: "GET", complete: function(jsondata, stat) { alert(jsondata.responseText); if (stat == "success") { alert("ew"); } }, error : function () { alert("error"); } }); },
Manikandan
if you required my whole HTML file, i will send you. please let me know. Thanks.
Manikandan
A: 

Hi Please find my entire HTML Code. is there any issues with this code ? the Ajax function i called in the datatype is not get executed.



jqGrid Demo







 
 
 
 

 

jQuery(document).ready(function(){ 
              jQuery("#list").jqGrid({
                           datatype: function (postData) {
                                $.ajax({ // THis function is not getting called @ any time.
                                    url: '1234.xml',
                                    type: 'POST',
                                    dataType: 'xml',
                                    data:postdata,
                                    error: function(){
                                        alert(1);
                                    },
                                    complete: function (xmlData, stat){
                                        alert(0);
                                    },  

                                });

                            },
                            colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],
                            colModel :[ 
                            {name:'invid',index:'invid', width:55}, 
                            {name:'invdate',index:'invdate', width:90}, 
                            {name:'amount',index:'amount', width:80, align:'right'}, 
                            {name:'tax',index:'tax', width:80, align:'right'}, 
                            {name:'total',index:'total', width:80,align:'right'}, 
                            {name:'note',index:'note', width:150, sortable:false} ],
                            pager: jQuery('#pager'),
                            rowNum:10,
                            rowList:[10,20,30],
                            sortname: 'id',
                            sortorder: "desc",
                            viewrecords: true,
                            pager: jQuery('#pager'),
                            imgpath: 'themes/basic/images',
                            caption: "My first grid"
}); 
}); 


Manikandan