implement signalR without jquery

2019-04-28 04:23发布

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?

1条回答
Luminary・发光体
2楼-- · 2019-04-28 04:53

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

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

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);
查看更多
登录 后发表回答