jsonPostBody.js 524 B

1234567891011121314151617
  1. //For those who use appplication/json instead of x-www-encoded
  2. //POST_data is the default variable that pass the body content into the VM
  3. sendJSONResp(JSON.stringify(POST_data));
  4. /*
  5. //Front-end side
  6. $.ajax({
  7. type: 'POST',
  8. url: '/form/',
  9. data: '{"name":"jonas"}', // or JSON.stringify ({name: 'jonas'}),
  10. success: function(data) { alert('data: ' + data); },
  11. contentType: "application/json",
  12. dataType: 'json'
  13. });
  14. //In the VM, "POST_data" variable will be set to the stringify content of '{"name":"jonas"}'
  15. */