不使用jquery实现signalR [英] implement signalR without jquery

查看:25
本文介绍了不使用jquery实现signalR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不使用 Jquery 的情况下实现 SignalR.我想为 Titanium 创建一个模块,但我不知道 SignalR 对 DOM 的依赖程度如何.jQuery 仅用于 ajax 请求吗?你认为这会有多难?

is it possible to implement SignalR without the use of Jquery. I want to create a module for Titanium, but I don't know how dependent SignalR is on the DOM. Is jQuery used just for the ajax request? how hard do you think this would be?

推荐答案

嗯,这不是不可能,但它会有点工作.您基本上需要在

Um its not impossible but it'll be abit of work. you will basicly need to re-write all jquery syntax ($...) in

Jquery.signalR.js

作为普通的 javascript.此外,您将只能进行低级连接,因为集线器"模型也需要 jquery.

as regual javascript. Also you will only be able to do low level connections as the "hub" model also requires jquery.

您可能需要包含 JSON.js,以便您可以像这样进行 ajax 调用.

You will probably need to include JSON.js so you can make your ajax call like this.

var the_object = {}; 
var http_request = new XMLHttpRequest();
http_request.open( "POST", url + "/negotiate, true );
...
http_request.onreadystatechange = function () {
    if ( http_request.readyState == 4 && http_request.status == 200 ) {
            the_object = JSON.parse( http_request.responseText );
        }
};
http_request.send(null);

这篇关于不使用jquery实现signalR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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