jsFiddle /echo/html not working with jQuery

不羁的心 提交于 2019-12-29 07:50:28

问题


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'
});

回答1:


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'
});


来源:https://stackoverflow.com/questions/4528392/jsfiddle-echo-html-not-working-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!