suresh.rajamani

Send Geometry JSON to aspx Handler using JQuery Ajax Submit

Discussion created by suresh.rajamani on Mar 18, 2012
Latest reply on Mar 19, 2012 by mcnaughty79
I am trying to send Javascript api Geometry JSON to Asp.net Handler using Jquery Ajax Submit.But i am getting javascript error while posting GEOMETRY JSON.
Here is my code i am trying.

    var jsondata = dojo.toJson(geometry.toJson());
       
        $('#ajax-button').click(function () {
            $('#frmUpload').ajaxSubmit({
                data: jsondata,
                contentType: "application/json; charset=utf-8",
                dataType: 'json',
                success: function (r) {
                    $('#ajax-results').html(r);
                    $('input:file').MultiFile('reset');
                }
            });
        });


If i pass the geometry like below it works fine.
 
    var jsondata = dojo.toJson(geometry.toJson());
       
        $('#ajax-button').click(function () {
            $('#frmUpload').ajaxSubmit({
                data: ' {"x":-10753913.140888039,"y":4632637.5074609965,"spatialReference":{"wkid":102100}}',
                contentType: "application/json; charset=utf-8",
                dataType: 'json',
                success: function (r) {
                    $('#ajax-results').html(r);
                    $('input:file').MultiFile('reset');
                }
            });
        });


Please help me how to send the Geometry JSON to server like this
dojo.toJson(geometry.toJson())

Outcomes