linux 中ajaxsubmit上传图片不好用

linux主机上用ajax不能加载远程页面吗?
[问题点数:100分,结帖人shenxian6]
linux主机上用ajax不能加载远程页面吗?
[问题点数:100分,结帖人shenxian6]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2013年5月 总版技术专家分月排行榜第一
2015年12月 总版技术专家分月排行榜第二2014年8月 总版技术专家分月排行榜第二2014年7月 总版技术专家分月排行榜第二2013年6月 总版技术专家分月排行榜第二
2013年5月 总版技术专家分月排行榜第一
2015年12月 总版技术专家分月排行榜第二2014年8月 总版技术专家分月排行榜第二2014年7月 总版技术专家分月排行榜第二2013年6月 总版技术专家分月排行榜第二
本帖子已过去太久远了,不再提供回复功能。当前访客身份:游客 [
这个人很懒,啥也没写
:"&!-- 一些段落 --& &p&foo&/p& &p&bar&/p&" 这里...
:5、当1端口的Memcached重启复活,连接...
:楼主的排版,说真的,看起来好累人。
:很详细的,收藏了。
:请问怎么配置webstorm使用oschina的git?...
:import java.io.F import java.io.IOExcepti...
:请问是java编写的么
:配色方案确实很不给力这个,这点sublime确实好很...
今日访问:52
昨日访问:41
本周访问:52
本月访问:805
所有访问:151131
JQuery读书笔记--JQuery-Form中的AjaxForm和AjaxSubmit的区别
发表于4年前( 18:46)&&
阅读(1493)&|&评论()
0人收藏此文章,
Query中的AjaxForm和AjaxSubmit使用差不多功能也差不多。很容易误解。
按照作者的解释:
ajaxForm不能提交表单。在document的ready函数中,使用ajaxForm来为AJAX提交表单进行准备。提交动作必须由submit开始
ajaxSubmit
马上由AJAX来提交表单。你可以在任何情况下进行该项提交。
option的参数
&{&&&& &&&&&&&target:&&&&&&&&
&target&element(s)&to&be&updated&with&server&response&&&&
&&&&&&&beforeSubmit:&&showRequest,&&
&pre-submit&callback&&&&
&&&&&&&success:&&&&&&&showResponse&&
&post-submit&callback&&&&
&& &&&&&&&
&other&available&options:&&&&
url:&&&&&&&url&&&&&&&&&//&override&for&form's&'action'&attribute&&&&
type:&&&&&&type&&&&&&&&//&'get'&or&'post',&override&for&form's&'method'&attribute&&&&
dataType:&&null&&&&&&&&//&'xml',&'script',&or&'json'&(expected&server&response&type)&&&&
clearForm:&true&&&&&&&&//&clear&all&form&fields&after&successful&submit&&&&
resetForm:&true&&&&&&&&//&reset&the&form&after&successful&submit&&&&
&& &&&&&&&
&$.ajax&options&can&be&used&here&too,&for&example:&&&&
timeout:&&&3000&&&&
示例代码摘自:
ajaxForm The following code controls the HTML form beneath it. It uses ajaxForm to bind the form and demonstrates how to use pre- and post-submit callbacks
&prepare&the&form&when&the&DOM&is&ready&
$(document).ready(
()&{& &&&&
&{& &&&&&&&&target:&&&&&&&&
&target&element(s)&to&be&updated&with&server&response&
&&&&&&&&beforeSubmit:&&showRequest,&&
&pre-submit&callback&
&&&&&&&&success:&&&&&&&showResponse&&
&post-submit&callback&
& &&&&&&&&
&other&available&options:&
url:&&&&&&&url&&&&&&&&&//&override&for&form's&'action'&attribute&
type:&&&&&&type&&&&&&&&//&'get'&or&'post',&override&for&form's&'method'&attribute&
dataType:&&null&&&&&&&&//&'xml',&'script',&or&'json'&(expected&server&response&type)&
clearForm:&true&&&&&&&&//&clear&all&form&fields&after&successful&submit&
resetForm:&true&&&&&&&&//&reset&the&form&after&successful&submit&
& &&&&&&&&
&$.ajax&options&can&be&used&here&too,&for&example:&
timeout:&&&3000&
&&&&};& & &&&&
&bind&form&using&'ajaxForm'&
).ajaxForm(options);& });& &
&pre-submit&callback&
&showRequest(formData,&jqForm,&options)&{& &&&&
&formData&is&an&&here&we&use&$.param&to&convert&it&to&a&string&to&display&it&
&but&the&form&plugin&does&this&for&you&automatically&when&it&submits&the&data&
&queryString&
&$.param(formData);& & &&&&
&jqForm&is&a&jQuery&object&encapsulating&the&form&element.&&To&access&the&
&DOM&element&for&the&form&do&this:&
&var&formElement&=&jqForm[0];&
& &&&&alert(
About&to&submit:&\n\n
&queryString);& & &&&&
&here&we&could&return&false&to&prevent&the&form&from&being&&
&returning&anything&other&than&false&will&allow&the&form&submit&to&continue&
&post-submit&callback&
&showResponse(responseText,&statusText)&&{& &&&&
&for&normal&html&responses,&the&first&argument&to&the&success&callback&
&is&the&XMLHttpRequest&object's&responseText&property&
&if&the&ajaxForm&method&was&passed&an&Options&Object&with&the&dataType&
&property&set&to&'xml'&then&the&first&argument&to&the&success&callback&
&is&the&XMLHttpRequest&object's&responseXML&property&
&if&the&ajaxForm&method&was&passed&an&Options&Object&with&the&dataType&
&property&set&to&'json'&then&the&first&argument&to&the&success&callback&
&is&the&json&data&object&returned&by&the&server&
& &&&&alert(
&statusText&
\n\nresponseText:&\n
&responseText&
& &&&&&&&&
\n\nThe&output&div&should&have&already&been&updated&with&the&responseText.
ajaxSubmit
The following code controls the HTML form beneath it. It uses ajaxSubmit to submit the form.
&prepare&the&form&when&the&DOM&is&ready&
$(document).ready(
()&{& &&&&
&{& &&&&&&&&target:&&&&&&&&
&target&element(s)&to&be&updated&with&server&response&
&&&&&&&&beforeSubmit:&&showRequest,&&
&pre-submit&callback&
&&&&&&&&success:&&&&&&&showResponse&&
&post-submit&callback&
& &&&&&&&&
&other&available&options:&
url:&&&&&&&url&&&&&&&&&//&override&for&form's&'action'&attribute&
type:&&&&&&type&&&&&&&&//&'get'&or&'post',&override&for&form's&'method'&attribute&
dataType:&&null&&&&&&&&//&'xml',&'script',&or&'json'&(expected&server&response&type)&
clearForm:&true&&&&&&&&//&clear&all&form&fields&after&successful&submit&
resetForm:&true&&&&&&&&//&reset&the&form&after&successful&submit&
& &&&&&&&&
&$.ajax&options&can&be&used&here&too,&for&example:&
timeout:&&&3000&
&&&&};& & &&&&
&bind&to&the&form's&submit&event&
()&{& &&&&&&&&
&inside&event&callbacks&'this'&is&the&DOM&element&so&we&first&
&wrap&it&in&a&jQuery&object&and&then&invoke&ajaxSubmit&
&&&&&&&&$(
).ajaxSubmit(options);& & &&&&&&&&
&!!!&Important&!!!&
&always&return&false&to&prevent&standard&browser&submit&and&page&navigation&
;& &&&&});& });& &
&pre-submit&callback&
&showRequest(formData,&jqForm,&options)&{& &&&&
&formData&is&an&&here&we&use&$.param&to&convert&it&to&a&string&to&display&it&
&but&the&form&plugin&does&this&for&you&automatically&when&it&submits&the&data&
&queryString&
&$.param(formData);& & &&&&
&jqForm&is&a&jQuery&object&encapsulating&the&form&element.&&To&access&the&
&DOM&element&for&the&form&do&this:&
&var&formElement&=&jqForm[0];&
& &&&&alert(
About&to&submit:&\n\n
&queryString);& & &&&&
&here&we&could&return&false&to&prevent&the&form&from&being&&
&returning&anything&other&than&false&will&allow&the&form&submit&to&continue&
&post-submit&callback&
&showResponse(responseText,&statusText)&&{& &&&&
&for&normal&html&responses,&the&first&argument&to&the&success&callback&
&is&the&XMLHttpRequest&object's&responseText&property&
&if&the&ajaxSubmit&method&was&passed&an&Options&Object&with&the&dataType&
&property&set&to&'xml'&then&the&first&argument&to&the&success&callback&
&is&the&XMLHttpRequest&object's&responseXML&property&
&if&the&ajaxSubmit&method&was&passed&an&Options&Object&with&the&dataType&
&property&set&to&'json'&then&the&first&argument&to&the&success&callback&
&is&the&json&data&object&returned&by&the&server&
& &&&&alert(
&statusText&
\n\nresponseText:&\n
&responseText&
& &&&&&&&&
\n\nThe&output&div&should&have&already&been&updated&with&the&responseText.
更多开发者职位上
1)">1)">1" ng-class="{current:{{currentPage==page}}}" ng-repeat="page in pages"><li class='page' ng-if="(endIndex<li class='page next' ng-if="(currentPage
相关文章阅读ajax无法正常使用,linux服务器_百度知道
ajax无法正常使用,linux服务器
刚传的网页,里面的ajax无法正常使用,按网上有些大神说的php设置了已经设置了header(&#39;Content-Type:text&#47;charset=utf-哗恭糕枷蕹磺革委宫莲8&#39;);js里面是request.setRequestHeader(&Content-Type&,&application&#47;x-www-form-urlencoded&);但是还是不能正常使用,求大神帮忙,万分感谢
服务器是linux的,编写时用的是windows系统的,在电脑上能正常使用,传服务器上就不行了
我有更好的答案
js 能不能用应该和服务器无关啊。这东西是哗恭糕枷蕹磺革委宫莲在浏览器端运行的。你不会是 js 文件本体被服务器那边识别错数据了吧?还有 Windows 我记得用的不是 utf8 ,中文系统都是 gb18030 ,你用什么程序写的?
那应该没问题才对……检查文件下载回来后情况吧。
其他类似问题
为您推荐:
linux服务器的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁新手园地& & & 硬件问题Linux系统管理Linux网络问题Linux环境编程Linux桌面系统国产LinuxBSD& & & BSD文档中心AIX& & & 新手入门& & & AIX文档中心& & & 资源下载& & & Power高级应用& & & IBM存储AS400Solaris& & & Solaris文档中心HP-UX& & & HP文档中心SCO UNIX& & & SCO文档中心互操作专区IRIXTru64 UNIXMac OS X门户网站运维集群和高可用服务器应用监控和防护虚拟化技术架构设计行业应用和管理服务器及硬件技术& & & 服务器资源下载云计算& & & 云计算文档中心& & & 云计算业界& & & 云计算资源下载存储备份& & & 存储文档中心& & & 存储业界& & & 存储资源下载& & & Symantec技术交流区安全技术网络技术& & & 网络技术文档中心C/C++& & & GUI编程& & & Functional编程内核源码& & & 内核问题移动开发& & & 移动开发技术资料ShellPerlJava& & & Java文档中心PHP& & & php文档中心Python& & & Python文档中心RubyCPU与编译器嵌入式开发驱动开发Web开发VoIP开发技术MySQL& & & MySQL文档中心SybaseOraclePostgreSQLDB2Informix数据仓库与数据挖掘NoSQL技术IT业界新闻与评论IT职业生涯& & & 猎头招聘IT图书与评论& & & CU技术图书大系& & & Linux书友会二手交易下载共享Linux文档专区IT培训与认证& & & 培训交流& & & 认证培训清茶斋投资理财运动地带快乐数码摄影& & & 摄影器材& & & 摄影比赛专区IT爱车族旅游天下站务交流版主会议室博客SNS站务交流区CU活动专区& & & Power活动专区& & & 拍卖交流区频道交流区
UID空间积分0 积分547阅读权限20帖子精华可用积分547 信誉积分114 专家积分0 在线时间46 小时注册时间最后登录
丰衣足食, 积分 547, 距离下一级还需 453 积分
帖子主题精华可用积分547 信誉积分114 专家积分0 在线时间46 小时注册时间最后登录
论坛徽章:0
背景描述:&#160;&#160; &#160;有一个表单,里面有姓名,昵称,电话等信息,然后提交的时候要进行一些判断,比如是不是没有填写,电话号码是否符合规则等等,判断不通过的话,则阻止提交。还有一项需求是判断昵称是否含有系统要过滤的词汇,而这些词汇的列表存放在服务器上,所以需要用到ajax来做。&#160;&#160; &#160;我的做法是在form里加上onsubmit=&return checkForm();&,如果checkForm()返回false,将阻止提交,如果返回true,表单就提交了。
问题描述:&#160;&#160; &#160;前面的那些判断都可以阻止,但是ajax的却不行,因为ajax是异步的,如:
function checkForm()
&#160;&#160;&#160;&#160;if ( document.getElementById('name').value == '' )
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert('名字不能为空');
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;requestAjax('test.php','par=val','get',callback);
function callback()
&#160;&#160;&#160;&#160;if ( ajax.responseText == 'N')
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;}
检测结果需要等到服务器返回,但是onsubmit不会等到ajax返回就已经提交了。
解决方案:&#160;&#160; &#160;后来通过网上搜索,找到一种解决方法。就是不用submit按钮,而是换成button,给予button一个click事件,button的onclick触发checkForm函数,然后如果ajax返回的时候N,就return false,如果是Y,就执行document.forms[&testf&].submit();代码如下:
function checkForm()
&#160;&#160;&#160;&#160;if ( document.getElementById('name').value == '' )
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert('名字不能为空');
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;requestAjax('test.php','par=val','get',callback);
function callback()
&#160;&#160;&#160;&#160;if ( ajax.responseText == 'N')
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;else
&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;document.forms[&testf&].submit();
&#160;&#160;&#160;&#160;}
本文来自ChinaUnix博客,如果查看原文请点:
&&nbsp|&&nbsp&&nbsp|&&nbsp&&nbsp|&&nbsp&&nbsp|&&nbsp

我要回帖

更多关于 ajaxsubmit ie8 的文章

 

随机推荐