带有ajax表单的加载页面后无法正常工作

时间:2016-05-15 21:40:02

标签: javascript jquery html ajax

我的表单在加载页面后提交,ajax无效 我的加载页面代码:

问题:将ajax表格加载为modalbox元素后



function account_list(url)
{
	$.ajax({
		type: 'get',
		url: url,
		beforeSend: function() {
			parsysm.loading(1);
		},
		success: function(data) {
			$('div#option-id-1').slideUp('slow', function(){
				$(this).html(data).slideDown('slow');
			});
		},
		error: function() {
			alert('Error Report!');
		},
		complete: function() {
			parsysm.loading(0);
		}
	})
}




并加载页面操作:



<form id="form-options-show" class="form-horizontal ">
 <div class="form-body">

<form id="form-options-show" class="fast-panel">
چینش&nbsp;&raquo;&nbsp;
<select class="inputcl1" name="order" size="1">
<option value="DESC"[desc] selected="selected"[/desc]>نزولی</option>
<option value="ASC"[asc] selected="selected"[/asc]>صعودی</option>
</select>
&nbsp;&nbsp;تعداد کاربران در صفحه&nbsp;&raquo;&nbsp;
<input name="total" class="inputcl1" type="text" style="width:25px;text-align:center" value="{total}" maxlength="3" />
&nbsp;&nbsp;جستجو&nbsp;&raquo;&nbsp;
<input name="search" class="inputcl1" type="text" style="width:150px" value="{search}" dir="ltr" />
[pages]
&nbsp;&nbsp;صفحه&nbsp;&raquo;&nbsp;
<select name="page" class="inputcl1" size="1">
[for pages]<option value="{number}"[selected] selected="selected"[/selected]>{number}</option>[/for pages]
</select>
[/pages]
&nbsp;&nbsp;
<input class="btn green" type="button" value="نمایش" onclick="account_list('{admin-page}&addon=account&'+parsysm.serialize('form-options-show'))" />
<input name="sort" type="hidden" value="{sort}" />
</form>
&#13;
&#13;
&#13;

但在加载页面模态框操作无效后 - &gt;模态框代码:

&#13;
&#13;
 <div class="modal fade" id="portlet-sms{id}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
							<h4 class="modal-title">ارسال پیامک به {name-show}</h4>
						</div>
						<div class="modal-body">
                             <div id="sms-ajax{id}"></div>
                            <form id="sms-form{id}" onsubmit="sms_send({id});return false">
                            <input type="tel" name="singlesms[number]" value="{mobile}" class="form-control"  maxlength="11" placeholder="09-- --- -- --" disabled /><br>
                            <textarea class="form-control" name="singlesms[msg]" placeholder="متن خود را وارد نمایید"></textarea>
                            
						</div>
						<div class="modal-footer">
                        	<input type="submit" class="btn blue" value="ارسال پیام"  />
							
							<button type="button" class="btn default" data-dismiss="modal">بستن</button></form>
						</div>
					</div>
					<!-- /.modal-content -->
				</div>
				<!-- /.modal-dialog -->
			</div>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

我不确定我是否清楚地理解了您的问题,但似乎您正在尝试使用数据中返回的新表单替换现有表单。

您需要在侦听表单的文档上编写侦听器并向其注册提交事件。如下所示:

$(document).on("submit", "form", callbackFunction());

答案 1 :(得分:0)

带有ajax的加载页面后的数据表格是:

<form id="sms-form17920" onsubmit="sms_send(17920);return false"></form>

此代码下的表单数据元素!!!