Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 9

chudong/phpquery

forked from wolferhua/phpquery
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
phpquery
/
jQueryServer
/
jQueryServer.js
phpquery
/
jQueryServer
/
jQueryServer.js
jQueryServer.js 5.87 KB
Copy Edit Raw Blame History
Tobiasz Cudnik authored 2011年05月18日 03:39 +08:00 . Initial commit.
/**
* jQuery Server Plugin
*
* Server-side Ajax requests supporting jQuery manipulations
* before sending content to the browser.
*
* Example:
* $.server({url: ${URL})
* .find('.my-class')
* .client(${CALLBACK});
*
* @version 0.5.1
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
* @link http://code.google.com/p/phpquery/wiki/jQueryServer
* @link http://code.google.com/p/phpquery/
*/
jQuery.extend({
serverConfig: function() {
if (typeof jQueryServerConfig != 'undefined')
return jQueryServerConfig;
return {};
}(),
server: function(options){
// set default url
if (! jQuery.serverConfig.url)
jQuery.serverConfig.url = jQuery('script[src$=jquery.js]')
.attr('src').replace(/jquery\.js$/, '')
+'jQueryServer.php';
// this is cache object
var objectCache = {};
// dump all jQuery methods, but only once
// $.each doesn't work ?
for( var i in jQuery.fn) {
// closure to preserve loop iterator in scope
(function(){
var name = i;
// create dummy method
objectCache[name] = function(){
// create method data object
var data = {
method: name,
arguments: []
};
// collect arguments
$.each(arguments, function(k, v){
data.arguments.push(v);
});
// push data into stack
this.stack.push(data);
// preserve chain
return this;
}
})();
}
/**
* Fetches results from phpQuery.
*
* @param {Function} callback Optional. Turns on async request.
* First parameter for callback is usually an JSON array of mathed elements. Use $(result) to append it to DOM.
* It can also be a boolean value or string, depending on last method called.
*/
objectCache.client = function(success, error){
// console.log(this.stack.toSource());
// success = success || function(){
// return $result;
// };
$.ajax({
type: 'POST',
data: {data: $.toJSON(this.stack)},
async: false,
// jQuery.server.config ???
url: jQuery.serverConfig.url,
// success: function(response){
// var $result = jQuery();
// $.each(response, function(v) {
// $result.add(v);
// })
// success.call(null, $result);
// },
// success: success,
success: function(response){
if (options['dataType'] == 'json')
response = $.parseJSON(response);
success(response);
},
error: error
})
}
// replace orginal method with generated method using cache (lazy-load)
jQuery.server = function(options){
// clone cache object
var myCache = jQuery.extend({}, objectCache);
myCache.stack = [options];
return myCache;
}
// returen result from new method (only done for first call)
return jQuery.server(options);
}
});
// toJSON by Mark Gibson
if (typeof $.toJSON == 'undefined') {
(function ($) {
var m = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
s = {
'array': function (x) {
var a = ['['], b, f, i, l = x.length, v;
for (i = 0; i < l; i += 1) {
v = x[i];
f = s[typeof v];
if (f) {
v = f(v);
if (typeof v == 'string') {
if (b) {
a[a.length] = ',';
}
a[a.length] = v;
b = true;
}
}
}
a[a.length] = ']';
return a.join('');
},
'boolean': function (x) {
return String(x);
},
'null': function (x) {
return "null";
},
'number': function (x) {
return isFinite(x) ? String(x) : 'null';
},
'object': function (x) {
if (x) {
if (x instanceof Array) {
return s.array(x);
}
var a = ['{'], b, f, i, v;
for (i in x) {
v = x[i];
f = s[typeof v];
if (f) {
v = f(v);
if (typeof v == 'string') {
if (b) {
a[a.length] = ',';
}
a.push(s.string(i), ':', v);
b = true;
}
}
}
a[a.length] = '}';
return a.join('');
}
return 'null';
},
'string': function (x) {
if (/["\\\x00-\x1f]/.test(x)) {
x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
var c = m[b];
if (c) {
return c;
}
c = b.charCodeAt();
return '\\u00' +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
});
}
return '"' + x + '"';
}
};
$.toJSON = function(v) {
var f = isNaN(v) ? s[typeof v] : s['number'];
if (f) return f(v);
};
$.parseJSON = function(v, safe) {
if (JSON)
return JSON.parse(v);
if (safe === undefined)
safe = $.parseJSON.safe;
if (safe && !/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(v))
return undefined;
return eval('('+v+')');
};
$.parseJSON.safe = false;
})(jQuery);
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

phpQuery是一个基于PHP的服务端开源项目,它可以让PHP开发人员轻松处理DOM文档内容,比如获取某新闻网站的头条信息。更有意思的是,它采用了jQuery的思想,你可以像使用jQuery一样处理页面内容,获取你想要的页面信息。
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/fireming/phpquery.git
git@gitee.com:fireming/phpquery.git
fireming
phpquery
phpquery
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /