How do I post Json data to a URL using AJAX? -
<script> $.ajax({ type: 'post', url: '/view', data:'{"s":"sam"}', contenttype: "application/json; charset=utf-8", datatype: 'json', success: function(data) { alert('data: ' + data); } }); </script>
when script gets loaded (400 bad request). since data starightforward, need know if there anyway can directly make request url, or easiest way map spring controller can read data external url?
thanks
can try way if not preferred direct way, btw, have not tested code...
var mydata = { name: value }; var request = $.ajax({ type: 'post', url: '/view', data: mydata, contenttype: "application/json; charset=utf-8", datatype: 'json', cache: false }); request.done(function(data){ alert(data); });
Comments
Post a Comment