jquery表单插件json无法获取
我将使用jquery form插件上传文件,并询问当响应数据为json时$.ajaxForm处理超时的现象。
服务器端的处理很顺利,响应数据以firebug看到的json形式返回。 但是,我认为$.ajaxForm无法获取数据。此后,它是已处理代码的一部分。
code $('#upload').ajaxForm({ cache: false, dataType: 'json', type: 'POST', error: function(xhr ,status ,error ) { alert('error occured. Status:' + status + ' --Status Text:' + error + ' --Error Result:' + xhr.statusText); }, timeout: 1000, dataType:'json', data:{ 'path':'path' , 'type':'type' }, complete: function(){ alert('complete'); }, success:function(data){ alert('success'); }, });
response
(firebug)
header
Connection close
Content-Length 155
Content-Type application/json; charset=utf-8
Status 200
data
json
{"type":"json","message":"complete process"}
<i>(A browser)</i>
①download json data
②alert('error occured. Status:timeout --Status Text:timeout --Error Result:n/a')
③alert('complete')
</pre>
当dataType为html时,能够处理成功。 而且,当是$.ajax时,json就成功了。 有解决方案吗?它适当地问。
I will upload the file by using jquery form plugin, and question on the phenomenon of process of $.ajaxForm becoming timeout when the response data is json.
Processing by the servers end is done without trouble, and the response data is returned in the shape along as long as it sees with firebug the json form.
However, I think that $.ajaxForm cannot acquire data. Hereafter, it is a part of processed code.
code $('#upload').ajaxForm({ cache: false, dataType: 'json', type: 'POST', error: function(xhr ,status ,error ) { alert('error occured. Status:' + status + ' --Status Text:' + error + ' --Error Result:' + xhr.statusText); }, timeout: 1000, dataType:'json', data:{ 'path':'path' , 'type':'type' }, complete: function(){ alert('complete'); }, success:function(data){ alert('success'); }, });
response
(firebug)
header
Connection close
Content-Length 155
Content-Type application/json; charset=utf-8
Status 200
data
json
{"type":"json","message":"complete process"}
<i>(A browser)</i>
①download json data
②alert('error occured. Status:timeout --Status Text:timeout --Error Result:n/a')
③alert('complete')
</pre>
When dataType was html, success was able to be processed.
Moreover, when it is $.ajax, json becomes success.
Are there a settlement plan?It asks suitably.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试设置
contentType
像try setting up the
contentType
like