yuli chika
yuli chika

Reputation: 9221

How to make a php a href post value use ajax?

I want to post a value using a href with target_self, but I do not want to refresh the page when it posts. How to add a ajax function?

<form name="info" id="info" method="post" action="index.php" >
<input name="name" type="hidden" value="test" /><br />
<a href="javascript:document.name.submit()">test</a>
<form>

Upvotes: 0

Views: 1057

Answers (1)

user529649
user529649

Reputation:

With ajax the page is never refreshed, you will just POST data to your webserver, if you want to stop page refresh after ajax just add this at the end of ajax function

return false;

assuming you use JQuery:

   $("form").submit(function(){

      $.ajax(); // Which needs some other stuff for making it useful
return false; //This will stop the page from refresh !
});

And please show some code so we can batter understand what you want.

Upvotes: 1

Related Questions