jQuery:将表单发布到模式窗口以预览输入的数据 [英] jQuery: Post form to a modal window for previewing the entered data

查看:140
本文介绍了jQuery:将表单发布到模式窗口以预览输入的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用jQuery的方法,以允许用户在提交要保存的表单之前查看表单的模式窗口预览".

I am looking for a way to use jQuery to allow a user to look at a modal window "preview" of a form before they submit the form to be saved.

我使用javascript进行工作,该表单被发布到一个名为Preview.php的文件中,该文件会循环访问所发布的信息.该脚本当前会打开一个新窗口.

I have this working with javascript, the form is posted to a file named preview.php that iterates through the posted information. The script currently opens a new window.

我想使用jQuery将表单发布到模态窗口中进行预览.有人对如何执行此操作有任何想法吗?

I would like instead to use jQuery to post the form to a modal window for previewing. Does anyone have any thoughts on how to do this?

这是我目前正在使用的:

This is what I am currently using:

<script language="JavaScript">
function preview(form) {
  form.target='_blank';
  form.action='http://example.com/preview.php';
  form.submit();
}
</script> 
<input type="button" value="preview" onclick='preview(this.form)'>

推荐答案

只需使用 http://jquery.malsup. com/表单插件.添加一个ID为'preview'的空div.

Just use the http://jquery.malsup.com/ form plugin. Add an empty div with a id of 'preview'.

$(document).ready(function() { 
    $('#form').ajaxForm({ 
        target: '#preview', 
        url: 'http://example.com/preview.php' 
    }); 
});

该表单将发布到preview.php文件中,并返回该文件中打印的所有文本.

The form will be posted to the preview.php file and return any text that is printed in that file.

这篇关于jQuery:将表单发布到模式窗口以预览输入的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆