Have you tried using firebug or chrome to see the requests and response that are getting created?
Also make sure that if you are passing any parameters that they ARE spelt exactly (including upper/lower case) the same in the calling javascript and your web method.
jqGrid makes ajax calls. its expecting the result to be in one of the format it expects. read the data manipulation sections of the docs. this sections defines what the xml must look like, or what the json must look like. if your webserver does not return
its results in one of these formats then you can extend the json reader or xmlreader, or build your own.
SonK
Member
6 Points
43 Posts
calling web-service by jQuery and bind results in jQgrid in asp.net 3.5
Jun 28, 2010 06:55 AM|LINK
hi to all,
I want to call web service through jQuery which returns array of object of class suppose listTask (Task name, task description....)
i tried by using $.get() but it can't work.
I have to papulate results in jQgrid.
I am trying to bind it in table. the code is-
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="js/jquery-1.3.2.js" type="text/javascript"></script>
<script type ="text/javascript">$(document).ready(
alert(
function() {"hi");// function getinfo() {
// var tab = "#list";
// var webmethod = "http://localhost/ProjectManagementWS/Authentication.asmx/ListTask";
var milestoneId = "1";// var param = "{'AuthToken':'" + token + "','MileStoneId':'" + milestoneId + "'}";
// $.ajax({
// type: "POST",
// url: webmethod,
// data: param,
// contentType: "application/json,charset=utf-8",
// dataType: "json",
// complete: processResult
// });$.
alert(
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
$.toJSON =
reviver =
}
};
get('http://localhost/ProjectManagementWS/Authentication.asmx/ListTask', {AuthToken:token,MileStoneId:milestoneId },function processResult(xData)
{"hi");
try {
var obj = eval(xData);
var td = '';var tn = new Array();
var td = new Array();var tt = new Array();
var ts = new Array();
var te = new Array();
var ta = new Array();
var s = new Array();
var pn = new Array();
var mn = new Array();
var e = new Array();
for (p in obj) {
var v = object[p];
var TaskName = v.TaskName;
var TaskDescription = v.TaskDescription;
var TaskTime = v.TaskTime;
var TaskStart_Date = v.TaskStart_Date;
var TaskEnd_Date = v.TaskEnd_Date;
var TaskAttachment = v.TaskAttachment;
var Status = v.Status;
var ProjectName = v.ProjectName;
var MileStoneName = v.MileStoneName;
var EmployeeId = v.EmployeeId;
alert(TaskName);
tn.push(TaskName);
td.push(TaskDescription);
ta.push(TaskAttachment);
te.push(TaskEnd_Date);
ts.push(TaskStart_Date);
tt.push(TaskTime);
s.push(status);
mn.push(MileStoneName);
e.push(EmployeeId);
pn.push(ProjectName);
}
}
alert(errrr);
catch (errrr) {//
}
$(
addTableRow($(
},
'#jQtab').show();'#jQtab'), tn, td, ta, te, ts, tt, s, mn, e, pn);'json');// }
alert(tds);
jQtab.each(
tds +=
}
function addTableRow(jQtab, tn, td, ta, te, ts, tt, s, mn, e, pn) {var tds = '';function() {var n = $('tr:last td', this).length;if (ad.length == 0) {'<tr><td>Sorry!! no results found !</td></tr>';else {for (var j = 0; j < ad.length; j++) {if (st[j] != 0) {// alert(st[j]);
// if (l[j] != 0.0) {
var $table = $(this);// alert(j);
//Number of td's
tds +=
tds +=
tds +=
tds +=
tds +=
tds +=
tds +=
tds +=
tds +=
tds +=
alert(pn[j]);
}
for (var i = 0; i < n; i++) {'<tr><td>' + tn[j] + ',</td>';'<td>' + td[j] + '</td>';'<td>' + ta[j] + '</td>';'<td>' + ts[j] + '</td>';'<td>' + te[j] + '</td>';'<td>' + tt[j] + '<td>';'<td>' + s[j] + '</td>';'<td>' + mn[j] + '</td>';'<td>' + e[j] + '</td>';'<td>' + pn[j] + '</td></tr>';// tds += '</tr>';
}
}
}
$(
$(
}
$(
$(
}
});
}
});
if ($('tbody', this).length > 0) {'#jQtab').find("tr:gt(0)").remove();'tbody', this).append(tds);else {'#jQtab').find("tr:gt(0)").remove();this).append(tds);</script>
<style type="text/css">
}
</
<
.style1 {width: 100%;</style>head>body>
<form id="form1" runat="server">
<div>
<div id="data">
</div>
<table class="style1" id="jQtab">
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
</
</
</form>body>html>
but above gode doesn't give any error but it prints nothing.
plz plzzzzzzzzzzzzzzzzzz help
nareshguree2...
Star
11118 Points
1997 Posts
Re: calling web-service by jQuery and bind results in jQgrid in asp.net 3.5
Jun 28, 2010 07:26 AM|LINK
there is many way, but for this you need to add a function in webservice.
vishwanath_h...
Participant
968 Points
179 Posts
Re: calling web-service by jQuery and bind results in jQgrid in asp.net 3.5
Jun 28, 2010 07:31 AM|LINK
hi,
Debug until your webmethod is returning data and make sure it is returning data. Then try the below
SonK
Member
6 Points
43 Posts
Re: calling web-service by jQuery and bind results in jQgrid in asp.net 3.5
Jun 28, 2010 09:40 AM|LINK
Error occured
permission denied to get XmlHttpRequest object!
MikeyBowler
Member
2 Points
1 Post
Re: calling web-service by jQuery and bind results in jQgrid in asp.net 3.5
Jun 28, 2010 11:50 AM|LINK
Hi,
Have you tried using firebug or chrome to see the requests and response that are getting created?
Also make sure that if you are passing any parameters that they ARE spelt exactly (including upper/lower case) the same in the calling javascript and your web method.
SonK
Member
6 Points
43 Posts
Re: calling web-service by jQuery and bind results in jQgrid in asp.net 3.5
Jun 28, 2010 12:37 PM|LINK
hi,
actually my webservice return result in xml format. because i am creating a class and sending array of object of that class.
so mainly the problem is how to parse xml file into jQuery..?
plzzzzzzzzzzzzzzzzzz help !!! (
sandy060583
Star
8714 Points
1624 Posts
Re: calling web-service by jQuery and bind results in jQgrid in asp.net 3.5
Jul 01, 2010 11:34 AM|LINK
i think you should use jTemplate for that..
here is very good example :
http://www.codedigest.com/Articles/jQuery/225_Creating_a_Simple_AJAX_Master-Details_View_Using_jQuery_JSON_and_jTemplates_in_ASPNet.aspx
Ramani Sandeep (My Blog)
(MCTS, MCC-2011)
bruce (sqlwo...
All-Star
36852 Points
5446 Posts
Re: calling web-service by jQuery and bind results in jQgrid in asp.net 3.5
Jul 03, 2010 03:46 AM|LINK
jqGrid makes ajax calls. its expecting the result to be in one of the format it expects. read the data manipulation sections of the docs. this sections defines what the xml must look like, or what the json must look like. if your webserver does not return its results in one of these formats then you can extend the json reader or xmlreader, or build your own.