再谈jQuery跨任何域 09 April 2012 11:25 Monday by 小屋 浏览(265)

跨域相关的文章老早写过几篇:

jquery url检测遇到的jquery跨域问题及JSONP的使用

PHP - 利用P3P实现跨域

HTTP和HTTPS跨域共享session解决办法

本文是对第一篇的实例补充。

js脚本

$.getJSON ('http://sjolzy.cn/?callback=? &a=1&b=2', function(data) {
    if (typeof(data) == 'object') {
        $.each(data,function(i,j){
            // ...
        });
    }
});

服务端代码

阅读全文>>

jquery ajax的async参数导致火狐浏览器闪屏 06 April 2012 11:15 Friday by小屋 浏览(368)

先提下关于jQuery的$.Ajax 的async的作用,

官方的解释是

async Boolean Default: true
By default, all requests are sent asynchronous (e.g. this is set to true by default). If you need synchronous requests, set this option to false. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.

async默认是true, 即为异步方式, $.Ajax执行后, 会继续执行ajax后面的脚步, 直到服务器端返回数据后, 触发$.Ajax里的success方法. 这时候执行的是两个线程.

我的出现闪屏的情况是:

$.ajax({
    type: "post",
    url: "index.php",
    data: { },
    async:false,

阅读全文>>

JQuery和Prototype区别小结 22 July 2011 16:35 Friday by小屋 浏览(1615)

jQuery使用得比较顺手也比较喜欢,不得已也要用Prototype,小小整理下区别。。

页面载入

  1. // JQuery
    
    
    
  2. $ ( document ). ready ( function () {
  3.         // Code
  4. });

 

  1. // JQuery Shorthand
    
    
    
  2. $ ( function () {
  3.         // Code
  4. });

 

  1. // Prototype
    
    
    
    

阅读全文>>

jQuery函数 - 左右抖动效果,用于提示 13 May 2011 13:50 Friday by小屋 浏览(977)

Wordpress博客后台登录输入错误的话登录窗口有左右抖动的效果。弄成jQuery函数方便调用(前提已载入jQuery包)

function shake(o){
    var $panel = $("#"+o);
    box_left = ($(window).width() -  $panel.width()) / 2;
    $panel.css({'left': box_left,'position':'absolute'});
    for(var i=1; 4>=i; i++){
        $panel.animate({left:box_left-(40-10*i)},50);

阅读全文>>

jQuery 3D文字特效(备用) 26 January 2011 21:10 Wednesday by小屋 浏览(2161)

源码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>jQuery 3D文字</title>
<style type="text/css">
body{
    font-family: Arial, "MS Trebuchet", sans-serif;
    background-color: #111;
}
#list{
    margin:0 auto;
    height:600px;

阅读全文>>