以下是我在html文件中使用的代码。问题是这个代码在Web浏览器中工作正常,表单数据发布在服务器上的数据库中,但是当我使用apache cordova构建android apk时,这个表单没有发布。
这是Java Script代码。
<!-- JAVASCRIPT -->
<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script type="text/javascript" src="js/modernizr.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jPushMenu.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('.toggle-menu').jPushMenu();
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#addServiceRequest').submit(function(){
var postdata = $('#addServiceRequest').serialize();
alert(postdata);
$.ajax({
type: 'POST',
url: 'http://server/add-service-request',
data:postdata,
crossdomain:true,
success: function(msg) {
console.log(msg);
alert(msg);
}
});
});
});
</script>
<!-- /JAVASCRIPT -->
这是表格部分
<!-- CONTENT SECTION -->
<div id="content-section">
<div class="offer-section">
<div class="heading">Service Request</div>
<div class="content">
<form id="addServiceRequest" role="form" class="form-horizontal" method="post" accept-charset="utf-8" data-ajax="false">
<div class="field01">
<textarea name="data[ServiceRequest][ac_id]" id="service_request_ac_id" class="icon05" placeholder="Account" style="width: 100%;"></textarea>
</div>
<div class="field01">
<textarea name="data[ServiceRequest][d_id]" id="service_request_description" class="icon05" placeholder="deal id" style="width: 100%;"></textarea>
</div>
<div class="field01">
<textarea name="data[ServiceRequest][service_category_list_id]" id="service_request_description" class="icon05" placeholder="service category list id" style="width: 100%;"></textarea>
</div>
<div class="field01">
<textarea name="data[ServiceRequest][description]" id="service_request_description" class="icon05" placeholder="Description" style="width: 100%;"></textarea>
</div>
<div class="field01">
<input type="submit" id="submit" data-inline="true" value="submit">
</div>
</form>
</div>
</div>
</div>
<!-- /CONTENT SECTION -->