Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I need to send ArcGIS JavaScript Geometry Object JSON string to Asp.Net Handler. I am using JQuery Ajax request to post the Geometry Data. I am not able to pass JSON geometry like this JSON.stringify(geometry.toJson()). Here is my code.

var jsondata = JSON.stringify(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'); < br >
    }
  });
});
share|improve this question
1  
Can you post an example of what JSON.stringify(geometry.toJson()) returns? –  Derek Swingley Mar 17 '12 at 20:17
    
It returns this {"x":-10753913.140888039,"y":4632637.5074609965,"spatialReference":{"wkid":10210‌​0}}. If i send this text it works fine ,i am able to receive this in server. <br> data: '{"x":-10753913.140888039,"y":4632637.5074609965,"spatialReference":{"wkid":1021‌​00}}' <br>But not working for this data: JSON.stringify(geometry.toJson()) –  SureshRajamani Mar 19 '12 at 6:49
    
I'm not nearly as experienced with jQuery so I'm not sure what's going on. I hate to be the person to suggest "do it another way" but have you tried with the methods bundled with the JSAPI? You would replace ajaxSubmit() with esri.request(). I would also use dojo.toJson() as it works in more browsers natively. –  Derek Swingley Mar 19 '12 at 17:38
    
Thanks Derek Swingley.I solved this issue by posting the json string in hidden field and sent to server and it works.Also dojo.toJson() is replaced by JSON.stringify(obj) This is new one by dojo. –  SureshRajamani Mar 20 '12 at 10:41
    
Glad you got it figured out. You should post your solution as an answer so that this question will show as answered. –  Derek Swingley Mar 20 '12 at 21:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.