.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

jQuery's ajax to call web service that returns ado.net dataset to xml

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net


     I try to use jQuery ajax to call web service that returns ado.net dataset which writes to xml, and after I get result client side, I will append to ol tag.

     It did not make it at the time of get result and try to loop the table tag.

     Thank you,





******* WebServiceCommon.cs    

    [ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
    public string GetAllLabsInXML()
        DataSet m_dsDataSet = new DataSet("pageDataSet");
        string m_szSQLConn = "Data Source=(local);Initial Catalog=abc;Integrated Security=False;uid=sa;pwd=abc;Pooling=false;";
        string _szSQL = @"Select LabID, Description From Lab";
        SqlConnection _objConn = new SqlConnection(m_szSQLConn);
        SqlDataAdapter _objDA = new SqlDataAdapter(_szSQL, _objConn);

        MemoryStream ms = new MemoryStream();
        m_dsDataSet.WriteXml(ms, XmlWriteMode.IgnoreSchema); 
        StreamReader sr = new StreamReader(ms, System.Text.Encoding.UTF8); 
        ms.Position = 0;
        String strXml = sr.ReadToEnd(); 

        return s

View Complete Post

More Related Resource Links

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

Jquery Ajax Call to Mvc Action tips.


I try to do a ajax call via the jquery api.

The scritp :

$("#sortColumn").click(function(e) {
                var columnName = $(this).attr('name');
                var sidx = columnName;
                var sord = '<%= (string)ViewData["sord"] == "asc" ? "desc" : "asc"%>';
                var page = '<%= ViewData["page"] %>';
                var rows = "5";
                type: "POST",
                url: "/Mailings/GetData2",
                data: {'sidx': sidx ,'sord': sord ,'page': page ,'rows':  rows },
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(response) {
                var jsonObject = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                error: function(xmlHttpRequest, textStatus, errorThrown) {
                    document.getElementById('infoContentHeader').innerHTML = xmlHttpRequest.responseText;


And the

Get xhr object in vb.net when error occured in ajax call using JQuery.

Hi Dude,   I have a big problem in Jquery ajax call. I am calling the web service whenever click the update button. I have a separate web service class, in which consist of few methods. When I calling the web service method, I have made the error handling and log the error information in db after that I have to override the "ex" that means error object to XMLHttpRequest. Is it possible to assign the sqlexception to ajax object (xhr) in vb.net? Please help me its much more useful for me.   Thank in advance.

jQuery Call to Web Service, with Punctuation

Hello everyone! I hope you're all having a nice week so far. I'm trying to call a web service and the passed string may have punctuation, depending on what the user types in. I currently have an HTML textbox and a jQuery call to the .NET web service.  I definitely think the string with punctuation fails because jQuery will send the string wrong, so I tried a few different javascript encoding functions I could find.  I was never able to encode it successfully and decode it in .NET, saving the string with punctuation.   Basically I have a textbox that a user can update their status in.  If the user wants to use punctuation, I'd like them to be able to.  How can I accomplish this with jQuery and .NET?

Problem when ajax enabled WCF Service returns EDM Objects

Hi there, Could you please help me with the following problem? - I have ajax enabled WCF service. It returns Customer Entity Type.  For example: [OperationContract]             public List<Customer> GetCustomers()        {            using (NorthwindEntities context = new NorthwindEntities())            {                return context.Customers.Take(10).ToList();            }        }  - But AJAX Client Library cannot display Customer( as Entity). I cannot see data in browser. Even it hits the breakpoint and returns 10 customers. - But if I make a plain class called "Customer2" with same fields and copy all the "Customer" into "Customer2" then it works. In this case I return List<Customer2>. Then it works like a champ and I can see customer in AJAX/DataView/List. - Why I need to create a class? Is this JSON problem? DataView accepts JSON data format. - I use VS2010, AJAX 4.0. - Do I need to add something else along with [OperationContract].   Regards, Rajan  

jquery ajax call does not work after adding routes

Hi.   I've added routes to my asp.net 4 website so that, for example the page: "~/Main/About/Careers.aspx"  is mapped to the url:  http://localhost/mysite/careers/   I'm using jquery to make an ajax call and it simply does not work after I've added the routing, I used the following code, and it remains stuck on the spinner image:$.ajax({ type: "POST", url: "Careers.aspx/SubmitApplication", data: "{" + paramList + "}", contentType: "application/json; charset=utf-8", dataType: "json", beforeSend: function () { $(".applySpinner").show() }, success: function (msg) { $(".applySpinner").hide(); // Replace the div's content with the page method's return. if (msg.d == "") { $(".applySuccess").hide(); $(".applyFailure").show(); return; } else $(".applyFailure").hide(); $(".sentTime").text(msg.d); $(".applySuccess").fadeIn(1000); } }); Thanks.  

How to bind distinct values to DropDownList from DataSet (as a result of a web service call)?


Hi there,

I'm trying to bind a dataset (where the data is coming from a webservice) to a dropdownlist; the problem is that I'm getting duplicates in the list... how can I display distinct values only:

drp_Brand.DataSource = ds.Tables[0];
            drp_Brand.DataTextField = "Brand";
            drp_Brand.DataValueField = "Brand";



Returning reference value from AJAX web method call on JQuery


I got this flag that I am checking for authenticated signed in users:


    <script type="text/javascript">
        $(document).ready(function () {
            $('#test').click(function () {

        function flag() {
            var _flag = "False";

JQuery Autocomplete Call WCF Service Method


I am trying to use the below code to call a wcf service method for Autocomplete functionality in a TextBox.  I have written the following query:

$(document).ready(function () {
            $("#<%= txtCompany.ClientID %>").autocomplete(http://localhost/PieScore/PieScore.Application.Services/EmployeeService.svc/GetTestCompanyList, {
                dataType: 'json',
                parse: function (data) {
                    var items = data.d;
                    var parsed = [];
                    for (var i = 0; i < items.length; i++)
                        parsed[i] = {

AJAX call to anonymous site returns 401 Unauthorized



I'm trying to do AJAX requests using jQuery to a custom aspx site which in turn gathers data from different lists and sites and in turn returns this to the client in a JSON object.

What I got:
A front facing page which does not require authentication.
A set of jQuery powered javascripts that should update certain parts of the frontpage with new content from the back end.
A server side custom page that builds and sends a JSON object with the proper data.

What I want:
A service that allows me to aggregate data from different lists and sites on the back end and feed this to the front page in a JSON object upon request. I don't need to write back updates to the list items on the server.

My problem: My current setup does not work for anonymous sites!

Also I was wondering if the way I'm doing this is the best (or preferred) way to perform such calls?

call Jquery ajax on ASP page loding.


Hi guys,

I want to avoid page refereshing or loding with the help of jquery ajax. Here i am attatch my asp page code.

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Shared/NimbleSchedule_H1_F1_L1.master"
    CodeBehind="DepartmentWizard.aspx.cs" Inherits="DepartmentWizard" %>
    <%@ MasterType VirtualPath="~/Shared/NimbleSchedule_H1_F1_L1.master" %>
<%@ Register Src="../Widgets/MyAccountNavigation.ascx" TagName="MyAccountNavigation"
    TagPrefix="NSMyAccountNavigation" %>
<asp:Content ID="cntHeader" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript" src="../Scripts/jquery.js"></script>
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('[id$=lnkCancel]').click(function () {
                return false;
                    type: "P

How to call external web service from jquery


I have a web service hosted on different server. I want to access it from my jquery. but I don't know how to do it.

I know how to call a native web service from JQuery, but I am struggling to call the external web service.

Can you please suggest me what I have to do ?


Thank you in advance.




Ajax call interrupting jQuery Draggable


I have a button that adds a set of div's to the page. Once these are added I then want to make a   "frame.draggable()" call in javascript. After this is done an Ajax call is made to another page to recieve some content for that frame. Everything seems to work fine the first time that I add a frame, but the draggable call fails on second and so on, but it works fine if i take out the Ajax call. 

 $('#content').append(frame); //Add Frame to content pane

 frame.draggable(); // Make frame Draggable

//Ajax call to get content
 $.get('DesiredContent.aspx', function (content) {
        frame.find('#myContent').html(content); });

return false;

If I comment out the Ajax call everything seems to work fine, however i dont get the content that i need. If i leave the call in then the second frame to be added will have the javascript fail at frame.draggable() saying that draggable is not a function. frame always has a unique id and if i put a break point in the javascript with firebug then i can get it to work as intended...

Cant figure this out, help would be much appreciated

Call web service and list product list from jquery or javascript




How can i Call web service and list product list to web page. I want do it from jquery or javascript. I want create peace of html code to paste any site to dsiplay some product. Like google adsense.

Through javascript and html codei want call to web service and get product and display site




jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

call JavaScript - jQuery code from ASP.NET Server-Side

jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

Making Ajax Callbacks to the Server Using jQuery with ASP.NET

In the first part of this article series I introduced jQuery's functionality and how it provides a rich client side programming model. This time around I'll expand on these concepts and show you how you can use jQuery in combination with ASP.NET using it as an AJAX backend to retrieve data. I'll also discuss how you can create ASP.NET controls and otherwise interact with jQuery content from ASP.NET pages in WebForms.

jQuery is just a JavaScript library so it will work seamlessly with ASP.NET both from page code as well as through backend driven code using the Page.ClientScript object or ScriptManager. You can use jQuery on its own as a client side and Ajax library that communicates with ASP.NET or you can use jQuery in combination with ASP.NET AJAX. The two actually complement each other quite well as jQuery provides functionality that the ASP.NET AJAX library does not and vice versa. For the most part the interaction between the two libraries is trouble free except for a few very rare edge cases.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend