Question

http://jsfiddle.net/YcK5X/ I'm wondering why this AJAX request doesn't return anything.

$.ajax({
    type: 'POST',
    url: '/echo/html',
    data: 'Echo!',
    success: function(data) {
        $('#ajax').html(data);
    },
    dataType: 'text/html'
});
Was it helpful?

Solution

The data you want echo:ed must be supplied in a POST parameter named html:

$.ajax({
  type: 'POST',
  url: '/echo/html/',
  data: {
    'html': 'Echo!'
  },
  success: function(data) {
    $('#ajax').html(data);
  },
  dataType: 'text/html'
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top