Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on

jquery/ajax to code behind

I have below object called resultObj  from jquery,
how can I pass to code behind c#?

  $.ajax({
                cache: false,
                type: "GET",
                async: false,
                dataType: "json",
                contentType: 'text/plain',
                url: GetDealerList + encodeURIComponent("(06234,'1111,asdfasdfasd,asdfasfasdf')"),
                success: function (data) {
                    $('#data').html(data);
                    alert(data);
                    if (data == null)
                        return;
                    resultObj = jQuery.parseJSON(data);
                    if (resultObj.Status != 'Failed') {
                        $('#json').html(createDealer(resultObj.Data));
                    }
                },
                error: function (xhr) {
                    $('#data').html(xhr.responseText);
                    //alert(xhr.responseText);

                }
            });
Avatar of Rob
Rob
Flag of Australia image

As described here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify use JSON.stringify to covert the js object to JSON format.  Then include that in your ajax request.
Avatar of ITsolutionWizard

ASKER

I need some sample codes to support what you mentioned....Thanks
url: GetDealerList + encodeURIComponent(JSON.stringify(resultObj)),
inside of code behind. how can i capture it?
The querystring will be sent and made available to your webmethod. I'm not familiar with .net but usually done with the Request class
Not sure which property should be used from request.
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial