0

I'm trying to do an HTTP Post using Javascript. I'm using the code reported here: JavaScript post request like a form submit

and it works fine.

But I need to remain in the same page while the HTTP Post is sent.

How can I do? Thx

Community
  • 1
  • 1
Filippo
  • 1
  • 1
  • 1

4 Answers4

1

AJAX?

Roberto Aloi
  • 30,570
  • 21
  • 75
  • 112
0

do it inside of an iframe.

do it as an AJAX post

Moin Zaman
  • 25,281
  • 6
  • 70
  • 74
0

I know it seems to be the perpetual hammer (Because it is) but try using jQuery. then you can do a real simple jQuery post

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

$.ajax({
type: 'POST',
url: url,
data: data,
success: success
dataType: dataType
});

or the shortest method if you don't need a return..

$.post("postTo.php", { name: $('#name').val(), data: $('#data').val(); } );

FatherStorm
  • 7,133
  • 1
  • 21
  • 27
0

AJAX

$('.button').click(function() {

 $.ajax({
  type: "POST",
  url: "whateveryourphpfileis.php",
  data: { whatyouare: "sending" }
})

});

How to Call a PHP Function on the Click of a Button

Community
  • 1
  • 1
Bad_1nternet
  • 11
  • 1
  • 7