我有在普通 jquery 移动页面上工作的 ajax 表单,但是当我在对话框上传输它时它不起作用。我的脚本没有读取 w/c 设置的点击事件,默认情况下它会在同一页面上发送所有值,这是错误的。我错过了什么吗?任何想法?提前致谢。
值正在发送到此 url,这是错误的:
http://localhost/MyFolder/views/maintenance/RegionAdd.html?triggerActivity=region&triggerAction=add®ionDesc=test&area=test222
代替:
http://localhost/MyFolder/model/maintenance/maintenance_process.php?triggerActivity=region&triggerAction=add®ionDesc=test&area=test222
请参阅下面的脚本。
JS:(位于 RegionAdd.html 上)
$(document).bind("pageinit", function(){
$("#submit-region").click(function(){
//var regionDesc = $("#regionDesc").val();
//console.log(regionDesc);
var formData = $("#ajaxForm").serialize();
$.ajax({
type: "GET",
url: "../../model/maintenance_process.php",
cache: false,
data: formData,
success: onSuccess
});
//e.preventDefault();
});
});
HTML5:(位于 RegionAdd.html 上)
<body>
<div data-role="page">
<form id='ajaxForm'>
<div data-role="header">
<h1>Add Region</h1>
<button type='submit' data-theme="a" data-icon="check" data-mini="true" id="submit-region">Save</button>
</div><!-- /header -->
<div data-role="content">
<div class="content-primary">
<input type="hidden" name="triggerActivity" id="triggerActivity" value="region" />
<input type="hidden" name="triggerAction" id="triggerAction" value="add" />
<ul data-role="listview">
<li data-role="fieldcontain">
<label for="regionDesc">Region</label>
<input type="text" name="regionDesc" id="regionDesc" value="" />
</li>
<li data-role="fieldcontain">
<label for="area">Area</label>
<input type="text" name="area" id="area" value="" />
</li>
</ul>
<h4 id="message"></h4>
</div>
</div><!-- /content -->
</form>
</div><!-- /page -->