0

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' parameter on test.html .and then retrieve complete data on index.html page

Test.html

<body>
   <div> welcome + //How to append name here ?? </div>
</body>

I can do it on php by "$_POST" command .... whats the alternative of it on HTML page ..

Final data will be display in index.htm

<body>
    <input id="button" type="submit" value="Go" />
    <div id="feedback">    </div>

</body>

Similar Posts:

How do I POST this data to an http server?
jQuery post not returning data
Jquery Post Data
jQuery - Redirect with post data

Community
  • 1
  • 1
user3487944
  • 267
  • 4
  • 9
  • 22

2 Answers2

3

$.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.

adeneo
  • 312,895
  • 29
  • 395
  • 388
0

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);
   }
});
ajtrichards
  • 29,723
  • 13
  • 94
  • 101