使用JQuery从post()接收响应

I had a script working using Ajax (POST method) via plain Javascript. Now I'm trying to learn JQuery as it seems easier but I am having problem with the response of a request

$.post('ajax/wrapper.php', {'desc':$('#description').val()},
        function(data){
            $('#something').html(data);
        });

When I do that the request is successfully sent. I can see the changes on my DB but the response is not showing up in div#something. I also tried

...
   $('#something').html($(data));
...

Thanks in advance

commenting out the following line worked: header("Content-type: text/xml; charset=iso-8859-1")

See this document and the dataType parameter in jQuery.ajax. You should either return HTML with a text/html MIME type, or set the dataType parameter to 'html':

$.ajax('ajax/wrapper.php', {
    data: {'desc':$('#description').val()},
    dataType: 'html',
    type: 'POST',
    success: function(data){
        $('#something').html(data);
    }
}).then(console.log); // debug

The first is preferable, as you really are returning HTML, and text/html is the correct MIME for that.

Try:

$('#something').html($.ajax({
  type: "POST",
  url: "ajax/wrapper.php",
  async: false
 }).responseText)

http://api.jquery.com/jQuery.ajax/

you can try it this way too

var jqxhr = $.post("ajax/wrapper.php",{desc:$('#description').val()}, function(data) {
      alert("success");
    });

show the data in the success callback

jqxhr.complete(function(data){
  $('#something').html(data);
});

You might to use the $.load

$("#something").load('ajax/wrapper.php', {'desc':$('#description').val()} );

Reference: http://api.jquery.com/load/

Try this:

$.post('ajax/wrapper.php', {'desc':$('#description').val()},
        function(data){
            $('#something').html(data);
        }, "html");