[CLOSED] for submit to webservice

  1. #1

    [CLOSED] for submit to webservice

    I am in trouble to make correct call to web service. Form values are being submitted correctly the only problem is that webservice respond in xml despite that [System.Web.Script.Services.ScriptService] is uncomment, It throws an error on response. Ext.JSON.decode(): You're trying to decode an invalid JSON String:
    for exampe
    createNewAssets: function () {
            var frm = Ext.getCmp('frmAddNewAsset').getForm();
                url: '../../stores/assets.asmx/saveNewAssets',
                cleanRequest: true,
                json: true, //it is not working 
                params: {
                    newAsset: frm.getValues(true)
                success: function (form, action) {
                    Ext.Msg.alert('Success', action.result.msg);
        public string saveNewAssets() { 
            return "{'success' : true , 'msg' : 'Success' }" ;
    Last edited by Daniil; Jul 10, 2013 at 3:51 AM. Reason: [CLOSED]
  2. #2
    Hi @odyssey,

    This option
    json: true
    deals with DirectEvents and DirectMethods, it doesn't deal with form submit.

    You can use the jsonSubmit method.

        url: 'some URL',
        jsonSubmit: true    
    Also I think you can remove these settings:
    cleanRequest: true,
    params: {
        newAsset: frm.getValues(true)
    Though, there is another problem. A JSON WebService response always contains "d" as a root. A form can't interpret it and will always fire a failure handler. Well, you can listen to a failure, then analyze a response. Though, personally, I would prefer to use an HTTP handler instead (ashx).

    Also you can use an XML WebService. Here is an example of possible response.
  3. #3
    There is another approach - using a FormPanel's ErrorReader.

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
            var submit = function () {
                    url: 'WebService1.asmx/Submit',
                    jsonSubmit: true,
                    success: function () {
                    failure: function () {
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Model runat="server" Name="ErrorModel">
                    <ext:ModelField Name="id" />
                    <ext:ModelField Name="msg" />
            <ext:FormPanel ID="FormPanel1" runat="server">
                        SuccessProperty="d.success" />
                    <ext:TextField runat="server" Text="Hello!" />
            <ext:Button runat="server" Text="Submit" Handler="submit" />
    using System.Web.Services;
    namespace Work2
        /// <summary>
        /// Summary description for WebService1
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        public class WebService1 : System.Web.Services.WebService
            public object Submit()
                return new
                    success = true
  4. #4
    Quite amazingly I could find submitted params in case where form is configured submitting json. Context.Request["Param1"] nor Context.Request.QueryString["Param1"] has any data but fiddler clearly shows that json being submitted. Strange
    Last edited by odyssey; Jul 02, 2013 at 7:57 AM.
  5. #5
    There are two approaches for a JSON WebService to get parameters.

    1. Changing a method signature to:
    public object Submit(string Param1, string Param2, ...)
    2. Reading parameters from Request.InputStream. Here is an example, search for the "Retrieve JSON data from Request.InputStream" header.
    Last edited by Daniil; Jul 16, 2013 at 4:20 AM.

Similar Threads

  1. [CLOSED] WebService params
    By odyssey in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 06, 2013, 6:07 AM
  2. Replies: 1
    Last Post: Jul 25, 2012, 9:52 AM
  3. submit?
    By marco.amusquivar in forum 1.x Help
    Replies: 0
    Last Post: Mar 25, 2012, 7:37 PM
  4. Help with WebService and Ext.net
    By xborderland in forum 1.x Help
    Replies: 3
    Last Post: Aug 11, 2011, 11:50 AM
  5. [CLOSED] Submit gridpanel data in form submit
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 14, 2010, 7:25 PM

Tags for this Thread

Posting Permissions