提交表单(jquery)并在彩盒中显示结果
我有一个想要提交的表单,该表单正在发布到 php 脚本来处理表单数据。
我需要做的是点击提交后有一个彩色框弹出窗口,其中包含 php 结果。
这可以做到吗?
这就是我一直在尝试的:
$("#buildForm").click(function () { // #buildForm is button ID
var data = $('#test-buildForm'); // #test-buildForm is form ID
$("#buildForm").colorbox({
href:"build_action.php",
iframe:true,
innerWidth:640,
innerHeight:360,
data: data
});
return false;
});
更新:这需要在 iframe 中返回 build_action.php 特别包含了这些结果的 css 和 js。
I have a form that I wish to submit which is posting to a php script to deal with the form data.
What I need to do is after hitting submit have a colorbox popup with the php results in it.
Can this be done?
This is what i've been trying:
$("#buildForm").click(function () { // #buildForm is button ID
var data = $('#test-buildForm'); // #test-buildForm is form ID
$("#buildForm").colorbox({
href:"build_action.php",
iframe:true,
innerWidth:640,
innerHeight:360,
data: data
});
return false;
});
UPDATE: This would need to be returned in an iframe as the
build_action.php has specific included css and js for those results.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
本文将帮助您解决问题
http://www.php4every1.com/tutorials/ jquery-ajax-教程/
this article will help you with the problem
http://www.php4every1.com/tutorials/jquery-ajax-tutorial/
您将需要了解使用 colorbox jQuery 插件的确切方法。但这里是我刚刚编写的一个基本(未经测试的)代码示例,希望可以帮助您上路。
如果您希望使用 jQuery 提交表单,假设您有以下表单和 div 来保存对话框数据:
您可以有一个 PHP 代码 (doAddition.php),它可能会执行两个数字的相加
您可以使用 jQuery 来检测提交代码,然后将数据发送到 PHP 页面并以 JSON 形式返回结果:
You will need to see the exact way to use your colorbox jQuery plugin. But here is a basic (untested) code example that I've just written to hopefully get you on your way.
If you wish to submit a form using jQuery, assuming you have the following form and div to hold dialog data:
You can have a PHP code (doAddition.php), which might do the addition of the two numbers
You can use jQuery to detect the submitting of the code, then send the data to the PHP page and get the result back as JSON:
这是简单的、未经测试的代码,但它会给你一个很好的起点,这样你就可以详细说明你想要的内容:
This is simple, untested code but it'll give you a good jumping off point so you can elaborate however much you please:
这就是我最终让它发挥作用的方式:
This is how I ended up getting it to work: