使用jquery表单提交工作正常,直到我添加了其他JS库
Using jquery form submission was working fine until I added other JS libraries
我正在使用jquery进行表单提交,它工作正常,但是当我将其与其他javascript库一起包含时,.ready可以工作,但其他事件不起作用。
$(document).ready(jQueryCodeOfReady);
function jQueryCodeOfReady()
{
// arrays of target tags ..... w.r.t id
var hashtable = new Array();
hashtable['frm'] = 'result';
hashtable['newaccount'] = 'content';
/********************** AJAX related Section Started ******************************/
function _(url , data ,dataType,type ,thetag)
{
/***Animation Code***/
$(thetag).html("<span style='"font-family:sans-serif; color:#274d87; background:url('loader.gif') no-repeat; padding-left:80px; width:164px; height:32px; '">wait ... </span>");
/***Animation Code ended***/
$.ajax({
type: type ,
url: url ,
data: data,
dataType: dataType,
success: function(data)
{
// show content etc in this tag
$(thetag).html(data);
} // ajax call back function
});
return false;
}
/*************************************************** AJAX related Section endeed *****************************************************************/
alert('sendf');
/*************************************************** Events Section Started *****************************************************************/
// Form submission using ajax ... when event happens then specific code called
$("form").submit(function (e)
{
// don't perform default html event behaviour
e.preventDefault();
// get form attribute and the taag in which the result should be shown
var formid="#"+$(this).attr('id'); // identify the form
var formaction=$(this).attr('action'); // the path where to move ahead after this event occurs
var targettag="#"+hashtable[$(this).attr('id')]; // hashtable array declared upthere
// get form data
var formdata = $(formid).serialize();
// give serverCall
_(formaction,formdata ,"text/html","POST",targettag );
});
$("a.searchlink2").click(function (e){
var path=$(this).attr('href');
var formdata='';
e.preventDefault();
// give serverCall
_(path,formdata ,"text/html","POST",'#result');
});
}
你可以看看文档的 将 jQuery 与其他库一起使用的部分。
相关文章:
- 在Jquery调用之间添加其他函数
- 如何在 Javascript 中向数组添加其他对象
- 在维护输入内容的同时添加其他字段
- 如何从帖子对象添加其他信息以在护照中注册用户
- 找到所有元素,如果没有类,则使用 jQuery 添加其他类
- 向ChartJS数据集添加其他属性
- 添加其他参数以使用fin上传器发送到服务器
- 如何在使用模式框的混合Form/HEF链接中添加其他GET参数
- JQuery文本编辑器-在工具栏中添加其他下拉列表
- 在响应之前向文档添加其他字段
- 如何向cordova.exec成功函数添加其他参数
- 如何在运行时向计算可观察量添加其他数组项
- 精彩弹出窗口 - 向 iframe 添加其他类
- 如何向数据表标头添加其他筛选器
- MD 数组:如果未找到值,则添加其他数组
- 从 youtube 向 yt.player 对象添加其他参数
- 向传单标记添加其他标记
- 高图表 - 添加其他导出选项而不会丢失默认选项
- 向 Google Maps API 添加其他功能
- 角度自动完成仅在删除符号时起作用,但如果添加其他符号则不工作