Click here to Skip to main content
15,887,485 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Best HTML editor? Pin
hightower1220-Oct-15 12:01
professionalhightower1220-Oct-15 12:01 
GeneralRe: Best HTML editor? Pin
mangu Santosh kumar23-Oct-15 17:50
mangu Santosh kumar23-Oct-15 17:50 
GeneralRe: Best HTML editor? Pin
DrewHolloway30-Oct-15 5:28
DrewHolloway30-Oct-15 5:28 
QuestionUnable to send using PHPMailer and Gmail Pin
Jassim Rahma15-Oct-15 5:34
Jassim Rahma15-Oct-15 5:34 
AnswerRe: Unable to send using PHPMailer and Gmail Pin
F-ES Sitecore15-Oct-15 23:09
professionalF-ES Sitecore15-Oct-15 23:09 
Questioncustom Css not working on MAC operating system Pin
Gurjit Singh8-Oct-15 22:57
Gurjit Singh8-Oct-15 22:57 
AnswerRe: custom Css not working on MAC operating system Pin
Mona sinha11-Nov-15 18:45
professionalMona sinha11-Nov-15 18:45 
QuestionPost Asp.net form using jquery to a webservice and process return data in xml format RSS Pin
Deepak Arjun7-Oct-15 20:23
Deepak Arjun7-Oct-15 20:23 
I am working on asp.net website. In one search page, i have to apend data on window scroll. form is a asp.net form with runat=server tag. I want to call a webmethod of a service or a method of a form, passing serialized form using jquery and get data back
in xml or json format back.I tried few things but getting errors.


is it possible?


can anybody point me to an article which does that?


below is sample code



C#
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
 
namespace WebApplication1
{
    /// <summary>
    /// Summary description for WebService1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
     [System.Web.Script.Services.ScriptService]
    public class WebService1 : System.Web.Services.WebService
    {
        [WebMethod]
        [ScriptMethod(ResponseFormat=ResponseFormat.Xml)]
        public string HelloWorld()
        {
            DataSet ds = new DataSet();
            ds.Tables.Add(new DataTable());
            ds.Tables[0].Columns.Add(new DataColumn("PersonId"));
            ds.Tables[0].Columns.Add(new DataColumn("PersonName"));
            ds.Tables[0].TableName = "Person";
 
            DataRow row = ds.Tables[0].NewRow();
            row[0] = "1";
            row[1] = "Sunny";
 
            ds.Tables[0].Rows.Add(row);
 
            row = ds.Tables[0].NewRow();
            row[0] = "2";
            row[1] = "Honey";
 
            ds.Tables[0].Rows.Add(row);
 
            string res = ds.GetXml();
            return res;
        }
    }
}


ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxFormPost.aspx.cs" Inherits="WebApplication1.AjaxFormPost" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
 
     
    <script type="text/javascript" language="javascript" src="jquery-1.6.2.min.js"></script>
 
    <script type="text/javascript" language="javascript">
        // JScript File
 
        function SearchClick() {
            alert('i am in');
            var frmValue = $("#form1")
                .serialize();
            alert(frmValue);
            $contentLoadTriggered = true;
            $.ajax(
                        {
                            type: "POST",
                            url: "/WebService1.asmx/HelloWorld",//
                            data: frmValue,
                            //dataType: "xml",
                            //contentType: "application/json; charset=utf-8",
                            async: true,
                            cache: false,
                            success: OnSuccess,
                            failure: function (xhr, textStatus, errorThrown) {
                                alert("The call to the server side failed. " + xhr.responseText);
                                alert("The call to the server side failed. " + textStatus);
                                alert("The call to the server side failed. " + errorThrown);
                            },
                            error: function (xhr, textStatus, errorThrown) {
                                console.log("The call to the server side failed. 2 " + xhr.responseText);
                                alert("The call to the server side failed. 2 " + xhr.responseText);
                                alert("The call to the server side failed. 2 " + textStatus);
                                alert("The call to the server side failed. 2 " + errorThrown);
                            }
                        }
            )
        }
 
 
        function OnSuccess(response) {
            alert(response);
            var xmlDoc = $.parseXML(response);
            var xml = $(xmlDoc);
            var person = xml.find("Person");
            alert(person.length);
             
        }
 
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <table class="container">
        <tr class="row">
            <td class="control-col">
                <label class="control-label" id="lbl1" visible="true">Person:</label>
            </td>
            <td class="control-col">
                <asp:TextBox  class="form-control"  runat="server" Name="txt1" id="txt1"></asp:TextBox>
            </td>
        </tr>
        <tr class="row">
            <td class="control-col">
                <label class="control-label" id="lbl2" visible="true">Price:</label>
            </td>
            <td class="control-col">
                <asp:TextBox  class="form-control"  runat="server" Name="txt2" id="txt2"></asp:TextBox>
            </td>
        </tr>
        <tr class="row">
            <td class="control-col"></td>
            <td class="control-col">
                <asp:Button ID="btnSearch" class="form-control" Width="100px" runat="server" Text="Search" OnClientClick="SearchClick();return false;"/>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>        

AnswerRe: Post Asp.net form using jquery to a webservice and process return data in xml format RSS Pin
F-ES Sitecore15-Oct-15 23:12
professionalF-ES Sitecore15-Oct-15 23:12 
QuestionTechnical image resource sites Pin
Md. Marufuzzaman25-Sep-15 19:24
professionalMd. Marufuzzaman25-Sep-15 19:24 
AnswerRe: Technical image resource sites Pin
Richard MacCutchan25-Sep-15 22:14
mveRichard MacCutchan25-Sep-15 22:14 
AnswerRe: Technical image resource sites Pin
Afzaal Ahmad Zeeshan25-Sep-15 23:27
professionalAfzaal Ahmad Zeeshan25-Sep-15 23:27 
Questiondoubt Pin
gowtham muthu25-Sep-15 3:36
gowtham muthu25-Sep-15 3:36 
AnswerRe: doubt Pin
User 41802545-Oct-15 10:04
User 41802545-Oct-15 10:04 
QuestionMessage Closed Pin
23-Sep-15 13:20
Member 1200729323-Sep-15 13:20 
QuestionHow to create secure login using angular js Pin
Member 1199959720-Sep-15 23:23
Member 1199959720-Sep-15 23:23 
SuggestionRe: How to create secure login using angular js Pin
Kornfeld Eliyahu Peter20-Sep-15 23:50
professionalKornfeld Eliyahu Peter20-Sep-15 23:50 
AnswerRe: How to create secure login using angular js Pin
Richard MacCutchan21-Sep-15 0:28
mveRichard MacCutchan21-Sep-15 0:28 
SuggestionRe: How to create secure login using angular js Pin
Richard Deeming21-Sep-15 2:41
mveRichard Deeming21-Sep-15 2:41 
AnswerRe: How to create secure login using angular js Pin
Richard Deeming21-Sep-15 2:47
mveRichard Deeming21-Sep-15 2:47 
QuestionHow to create secure login procedure in angular js Pin
Member 1199959720-Sep-15 23:22
Member 1199959720-Sep-15 23:22 
Questionsteps to learning professional front & back -end develpoment Pin
programmerinthemaking16-Sep-15 10:29
programmerinthemaking16-Sep-15 10:29 
AnswerRe: steps to learning professional front & back -end develpoment Pin
Richard MacCutchan16-Sep-15 21:52
mveRichard MacCutchan16-Sep-15 21:52 
AnswerRe: steps to learning professional front & back -end develpoment Pin
Blikkies17-Sep-15 3:02
professionalBlikkies17-Sep-15 3:02 
AnswerRe: steps to learning professional front & back -end develpoment Pin
Nathan Minier30-Sep-15 6:37
professionalNathan Minier30-Sep-15 6:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.