存档

文章标签 ‘jquery’

PHP如何处理jquery post过来的$('#form').serialize()数据

2011年11月28日 没有评论

如果你使用jquery的form表单中serialize提交数据到后台,例如:$('#form').serialize()。在php处理端你不用任何处理,跟普通的from提交一样,使用$_GET[‘varname’]或$_POST[‘varname’]就能取到数据。

 

jquery里form的serialize实际是只是把表单中的数据组装成"varname=val&var2=val2"这种样子,看到这个你应该知道PHP端不需要处理了吧。

分类: PHP 标签: ,

解决ecshop不支持jquery的问题

2010年4月16日 8 条评论

一、上传js目录到ecshop的根目录

二、page_header.lbi 中添加 {insert_scripts files='jquery-1.4.2.min.js,json.js,'}

三、替换文件

替换原则:
  替换 *.toJSONString() 为 jQuery.toJSONString(*)
  替换 *.parseJSON() 为 jQuery.parseJSON(*)

修改方法:
1.transport.js中的修改内容
  替换 params.toJSONString() 为 jQuery.toJSONString(params)
  替换 result.parseJSON() 为 jQuery.parseJSON(result)

2.替换commet_list.lbi中的cmt.toJSONString()换为jQuery.toJSONString(cmt)

以下类似,只给出修改的行数,具体按照替换原则进行即可。
3.修改js/index.js 第44行

4.修改js/common.js 第34行、第837行、第1043行

5.修改js/compare.js 第49行、第67行、第133行

6.修改flow.dwt 第138行、第199行

7.修改compare.dwt 第20行

8.修改admin/templates/topic_edit.htm 208行
  menu.htm 336行,template_setup.htm 170行,
  topic_edit.htm 286行

9.修改admin/js/selectzone.js 144行,179行

js修改文件jquery_ecshop

注:
去掉transport.js中的json部分,加入jquery.json插件到js/json.js
把json.js中的evalJSON换成parseJSON,toJSON换成toJSONString

jQuery.noConflict()

运行这个函数将变量$的控制权让渡给第一个实现它的那个库。
这有助于确保jQuery不会与其他库的$对象发生冲突。在运行这个函数后,就只能使用jQuery变量访问jQuery对象。例如,在要用到$("div p")的地方,就必须换成jQuery("div p")。

--------------------------------------------------------------------------------

Run this function to give control of the $ variable back to whichever library first implemented it.
This helps to make sure that jQuery doesn't conflict with the $ object of other libraries. By using this function, you will only be able to access jQuery using the 'jQuery' variable. For example, where you used to do $("div p"), you now must do jQuery("div p").
返回值
jQuery

示例
将$引用的对象映射回原始的对象。

jQuery 代码
jQuery.noConflict(); 
// 使用 jQuery 
jQuery("div p").hide(); 
// 使用其他库的 $() 
$("content").style.display = 'none';  

--------------------------------------------------------------------------------

恢复使用别名$,然后创建并执行一个函数,在这个函数的作用域中仍然将$作为jQuery的别名来使用。在这个函数中,原来的$对象是无效的。这个函数对于大多数不依赖于其他库的插件都十分有效。
jQuery 代码
jQuery.noConflict(); 
(function($) { 
  $(function() { 
    // 使用 $ 作为 jQuery 别名的代码 
  }); 
})(jQuery); 
// 其他用 $ 作为别名的库的代码 
 

--------------------------------------------------------------------------------

创建一个新的别名用以在接下来的库中使用jQuery对象。

jQuery 代码
var j = jQuery.noConflict(); 
// 基于 jQuery 的代码 
j("div p").hide(); 
// 基于其他库的 $() 代码 
$("content").style.display = 'none';

分类: 网站 标签: ,
普人特福的博客cnzz&51la for wordpress,cnzz for wordpress,51la for wordpress