Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • vladzebu 59 posts 346 karma points
    Apr 11, 2012 @ 20:55
    vladzebu
    0

    Umbraco Base Json Param

    Hi , 

    i have next method : 

     public static bool MyMethod(string inputString)

    I'm trying to call this function with Ajax Jquery  

     jQuery.ajax({

                  type: "POST",

                  url: "/base/myAlias/ MyMethod /",

                  data: '{ "data": "Test" }',

                  contentType: "application/json; charset=utf-8",

                  dataType: "json",

                  async: true,

                  cache: false,

                  success: function (msg) {

                  alert(msg.d);

                  }

                  });

                  });

        I debug input parameter is alway string.Empty . 
        How can i resolved to get correct JSon data ('{ "data": "Test" } in this case ) .
       Cheers , 
       Vlad.  
       
       

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 12, 2012 @ 14:08
    Tom Fulton
    0

    Hi,

    Since you are doing a POST you'll want to use something like HttpContext.Current.Request["data"] instead of accessing inputString.  To pass it as an actual parameter you need to do a GET to "/base/myAlias/MyMethod/yourDataGoesHere" - but it's probably best to do a POST if you have JSON data.

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft