关于jQuery.ajax 进入success后,返回错误的问题,求各位大神帮助 这个是不ajax的错误 是后台代码出错了,只能在后台照原因。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一看就是data,你服务器就发出这个data, 你的动态页返回200状态,标准json格式字符串就不会执行error回调至于你动态页加了try..catch容错配置客户端是扑捉不到的,你可以通过msg来判断success: function(msg){if(msg.ajaxResult=='fail')alert('出错鸟'+msg.errorStack)else console.log("ajax success"); console.log(msg);} =========================================================== function Form(){ jQuery.ajax({ url: $("#Form").attr('action'), data: $('#Form').serialize(), type: "POST", timeout: 30000, success: function(msg) { if(msg.ajaxResult=='fail')alert('出错鸟'+msg.errorStack) else console.log("ajax success"); console.log(msg); }========================================================加上楼主标红的判断代码,1.控制台显示是 ajax success2.还是报{"ajaxResult":"fail","errorStack":"java.lang.NullPointerException\n\tat,"msg":null} jQuery.ajax({dataType:'json', url: $("#Form").attr('action'), data: $('#Form').serialize(), type: "POST", timeout: 30000, =========================================================== function Form(){ jQuery.ajax({ url: $("#Form").attr('action'), data: $('#Form').serialize(), dataType:'json', type: "POST", timeout: 30000, success: function(msg) { if(msg.ajaxResult=='fail')alert('出错鸟'+msg.errorStack) else console.log("ajax success"); console.log(msg); }========================================================结果是出错鸟java.lang.NullPointerException 那不就是出错了,然后输出错误信息。楼主你到底要干嘛。。NullPointerException 论坛中看到 ‘一般的NullPointerException的问题都是在跳转页面去取值的时候得到的是null值’,怎么理解呢 $('#Form').serialize()获得data数据等号后为空造成的,也许不应该采取serialize()方式获取。 alert($('#Form').serialize());检查一下表单数据是否取到还需检查数据格式是否符合服务端要求 ===========================================================var data = $('#submitForm').serialize(); function Form(){ alert (data); jQuery.ajax({ url: $("#Form").attr('action'), data: $('#Form').serialize(), dataType:'json', type: "POST", timeout: 30000, success: function(msg) { if(msg.ajaxResult=='fail')alert('出错鸟'+msg.errorStack) else console.log("ajax success"); console.log(msg); }========================================================获取表单数据,很多为空,且不是网页上填写的数据。我先手动输入data试试。等大神,提示更好的方法获取data 现在还有人用alert.你的目标数据是怎样的格式。你现在的数据又是怎样的格式。只能空想。 不用鼠标触发js 关于文件上传加密 有没监控dom元素是否发现变化的事件 window.location.href跳转之后怎么获得后面带参数的值急 15[^4,\D]这个正则表达式是什么意思? 郁闷啊,一段简单的代码,为什么FF就是不兼容?? 关于浏览器窗口关闭时的问题 哪位好心人能帮我将以下vbscript代码转成javascript,万分感谢 怎样判断页面已经载入完毕??(在线等) 我想用javascript编写一个抽奖程序,不知道那位DX可以帮忙 事件返回false时,IE浏览器可以,FireFox浏览器不行. 这种图片切换效果怎么实现,求代码和解释
{
if(msg.ajaxResult=='fail')alert('出错鸟'+msg.errorStack)
else console.log("ajax success");
console.log(msg);
}
function Form(){
jQuery.ajax({
url: $("#Form").attr('action'),
data: $('#Form').serialize(),
type: "POST",
timeout: 30000,
success: function(msg)
{
if(msg.ajaxResult=='fail')alert('出错鸟'+msg.errorStack)
else console.log("ajax success");
console.log(msg);
}========================================================加上楼主标红的判断代码,
1.控制台显示是 ajax success
2.还是报{"ajaxResult":"fail","errorStack":"java.lang.NullPointerException\n\tat
,"msg":null}
dataType:'json',
url: $("#Form").attr('action'),
data: $('#Form').serialize(),
type: "POST",
timeout: 30000,
function Form(){
jQuery.ajax({
url: $("#Form").attr('action'),
data: $('#Form').serialize(),
dataType:'json',
type: "POST",
timeout: 30000,
success: function(msg)
{
if(msg.ajaxResult=='fail')alert('出错鸟'+msg.errorStack)
else console.log("ajax success");
console.log(msg);
}========================================================
结果是
出错鸟java.lang.NullPointerException
检查一下表单数据是否取到
还需检查数据格式是否符合服务端要求
var data = $('#submitForm').serialize();
function Form(){
alert (data);
jQuery.ajax({
url: $("#Form").attr('action'),
data: $('#Form').serialize(),
dataType:'json',
type: "POST",
timeout: 30000,
success: function(msg)
{
if(msg.ajaxResult=='fail')alert('出错鸟'+msg.errorStack)
else console.log("ajax success");
console.log(msg);
}========================================================
获取表单数据,很多为空,且不是网页上填写的数据。
我先手动输入data试试。
等大神,提示更好的方法获取data
你的目标数据是怎样的格式。
你现在的数据又是怎样的格式。
只能空想。