开发者

replacing php form with new content on submit using jquery

开发者 https://www.devze.com 2023-01-24 01:34 出处:网络
I have a poll with the following action echo(\"\\t<form class=\\\"vote\\\" method=\\\"post\\\" action=\\\"\" . $url . \"vote.php\\\">\\r\\n\");

I have a poll with the following action

echo("\t<form class=\"vote\" method=\"post\" action=\"" . $url . "vote.php\">\r\n");

vote.php calls several validating functions and finally displays the poll results

开发者_开发百科

What I want is when the submit button is pressed, using jQuery, call vote.php and display the vote result replacing the poll.

Thanks in advance.


You can use jquery to submit your data. You can find plenty of resources if you search for it. Here's one.


I would have vote.php echo the html for the poll results. You can then use JQuery to replace the content of the poll's div with the poll results using the success() function.


Something like this, probably (untested):

$('.vote').submit(function()
{
  var action = $(this).attr('action');
  var data = $(this).serialize();
  $('#insert-here').load(action, data));
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号