服务器端jQuery [英] Server-side jquery

查看:126
本文介绍了服务器端jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个用perl或python编写的脚本.编写在字符串上使用jQuery选择器的函数的最简单方法是什么?即能够做到:

Say I have a script written in perl or python. What's the easiest way to write a function that would use jquery selectors on strings as part of it? i.e. to be able to do:

jquery_selector('table.new#element', text)

其中,jquery_selector是对存储在text中的html字符串运行jquery选择器的函数.即使只限于返回字符串(不是完整的jquery对象),它仍然会非常有用.也就是说,如果您需要提供一个JavaScript函数作为回调,这将使结果呈现为脚本语言可理解的内容:

where jquery_selector is a function that runs a jquery selector on the html string stored in text. Even if it was just limited to returning strings (not full jquery objects), it would still be really useful. i.e. if you were required to give a javascript function as a callback which would render the results to something comprehensible in the scripting language:

jquery_selector('table.new#element, text, 'function(e){return e.val()}')

它将以列表的形式返回回调的结果.

And it would return the results of the callback as a list.

我意识到大多数语言都有dom库,但是jquery比大多数语言要好得多.

I realize that there are dom libraries for most languages, but jquery is so much better than most of them.

我不是在问具有类似jquery语法的本机库.我猜将需要运行jquery的浏览器的API?还是这是node.js的作用?

I am not asking about native libraries which have a syntax like jquery. I guess what would be needed is an API to a browser which jquery would run on? Or is this what node.js does?

推荐答案

如果我正确理解了您的问题,那么您想要的就是类似 phantom的东西. js . PhantomJS是带有JavaScript API的无头WebKit.您可以将jquery注入其中,并使用所有jquery选择器来操纵dom.您还可以使其像独立服务器一样工作.

if i understand your question correctly you want is something like phantom.js. PhantomJS is a headless WebKit with JavaScript API. you can inject jquery into it and use all the jquery selectors to manipulate the dom. you can make it work like a standalone server aswell.

这篇关于服务器端jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆