Skip to content Skip to sidebar Skip to footer

Jquery $.post Post Data

this is my post method :(Code is as per tutorial ) $.post('test.htm',{name:test_name'}, function (data) { $('#feedback').html(data); }); I want to append'name' pa

Solution 1:

$.post accepts an object to be passed to the server, like so

$.post('test.htm', {name: "test_name"}, function (data) {
    $('#feedback').html(data);
});

of course, in a .htm page there is nothing to catch the request, you'll need a serverside language of some sort.

Solution 2:

You can use something like this:

$.post('test.htm', {name: "test_name"}, function (data) {
    $('#feedback').html(data);
});

Or you could use jQuery's full $.ajax function

$.ajax({
   url: 'test.htm',
   type: 'POST',
   dataType: 'html',
   cache: false,
   data: 'name=test_name',
   error: function (e){

   },
   success: function (data){
      $('#feedback').html(data);
   }
});

Post a Comment for "Jquery $.post Post Data"