Jquery - Publish and Subscribe? - javascript

Is there such a thing as publish and subscribe for use with jquery to send msgs from 1 javascript page to another.. Using the same idea behind ajax publish and subscribe?
I would like to use the pattern for communication between pages, i have been using a javascript framework lately but recently converted back to jquery and would love to continue using this.
Any ideas where i should start? and which implementation to use if more than 1 exists..
Thanks

jQuery is a simple JS toolkit that makes working with the DOM easier.
What you need is something like strophe. It uses XMPP via BOSH. There is a video, where the creator describes it.
Another option is the Bayeux protocol. There are implementations in Dojo and jQuery.

jQuery is just a library providing set of utility functions. It is not a programming language. It is not Ajax.
Ajax is a design pattern. It is not a programming language. It is not a library.
Ajax publish-subscribe is just a more specific design pattern that uses the Ajax pattern.
There is no reason it can't be implemented using jQuery.

I think you're looking for an implementation of the bayeux protocol written in jquery.
A comet plugin that uses the bayeux protocol can be found here

You are trying to use the observer pattern to synch the UI?
I think this should help you
Have a look at the code behind
basically when you click on the check boxes on top the behaviour of the link changes
the code is very small
I love it
Cheers

Check out http://laharsub.codeplex.com. This is an open source project that provides publish/subscribe capability using HTTP APIs and comes with a jQuery extension that provides usable OM for Ajax applications.

Related

Implement Reverse AJAX using DOJO javascript

I want to implement Reverse AJAX using DOJO javascript framework.
Does DOJO provide support out-of-the-box similar to others like DWR?
I am using the latest DOJO.
Any reference/examples would be great.
Also what changes would need to be done on the server-side ? I am using Java.
Well, there is the dojox/socket module which allows you to any WebSocket or Comet (= HTTP long polling) solution.
An alternative is the CometD project, this is a solution that uses long polling and allows you to communicate with Java applications (using the CometD Java library) and JavaScript applications (using the CometD Dojo library).
However, it is not out of the box with Dojo but is a separate project (the JavaScript lib was included in older versions though).
Your code setup will change, obviously. First you need to be able to run the CometD Java service, and then you can use ServerSession to publish data or ClientSession to subscribe at the Java side. Going into detail would be too broad, but you should probably read the reference guide.

How to consume webservice in javascript

please tell me how to consume webservice (.net) using javascript.
its SOAP.
Thanks
You use AJAX.
In particular the XMLHttpRequest object.
Look at the jQuery ajax API - it makes AJAX easier to use.
I don't think there is a Javascript library that consumes SOAP out of the box. Dojo offers a lot of functionality in that direction, RPC-calls for example, and is probably the one that comes closest.
IBM did some work there that you might want to check out.
This (including Dojo) is a lot of non-trivial stuff to learn but SOAP is a nasty beast, if you really need to interface to a SOAP service with JS you will have to invest some time.
See:
http://www.ibm.com/developerworks/web/library/wa-dojowebresponse/index.html?ca=drs-
SOAP Requests in Dojo
Both .asmx and .svc (wcf) expose javascript enabled bindings - this is easy to find on the internet.
Example:
http://dotnetbyexample.blogspot.com/2008/02/calling-wcf-service-from-javascript.html
Normally you just append /js to the url of the endpoint and javascript providing a proxy is returned.
This proxy code relies on the ASP.NET AJAX framework, but you can easily use it with any other ajax-enabling framework by using this shim.

jQuery, Web Application Framework?

For the longest time I've used jQuery to hack together web sites. Now I'm interested in making a web application (one page load for the entire site to function, like Gmail).
Are there any jQuery Frameworks or practices that I can leverage to build my application so I don't have to recreate the wheel, or hack something together as I go?
Thanks
One of the (not so) many options is JavascriptMVC, which is pretty cool and I've used it for one midium-size project.
It's website is pretty discouraging, but give it a chance and watch the video. One possitive aspect is that it's creator always answers really fast in JMVC's google group.
But, actually, if I had to remake the project I mentioned, I would not use it, as jQuery provides (almost) all JMVC's functionality, you just have to get used to it. For an example in how to handle big apps with jQuery, I would recommend you to watch this video between others of Alex Sexton and other members of the yayQuery podcast.
I honestly don't know how someone could say jQuery provides almost all of JMVC's functionality. Yes, you can do a lot of similar things with jQuery, but you would have to write it an maintain it yourself.
Here's a quick list of what JavaScriptMVC provides that jQuery does not: (read more of them at http://jupiterjs.com/news/javascriptmvc-features)
Dependency Management
Building / Compression
Logging
Organized Folder Structures
Package Management
Code Cleaning
Functional Testing
Client Side Templates
A bunch of delegatable special events (drag-drop, hover, resize, etc)
A bunch of dom utilities
Language Extensions
An awesome widget factory
Documentation
Have you looked into Sammy.js? It's an mvc framework built on JQuery and is very beginner friendly. http://code.quirkey.com/sammy/

What kind of architecture is good for my JavaScript software?

I am writing a software for a website where people can manage the website content. The interface is similar to Windows with all those windows floating around, click-able components, type-able text fields, etc. The admin interface is written in JavaScript, HTML and CSS. I'm wondering what kind of architecture should I apply to my admin system before it's too late (I've written some minor code so far).
For example, for the PHP back-end I'm using MVC, but what should I use for the client-side JavaScript admin system?
If you were developing an GWT application, you would automatically have an architecture. For custom JS, with AJAX calls a two-tier architecture would be more than sufficient. However, I prefer going the event-driven way, where I have a layer full of listeners and another layer of handlers. I use closures for the most part and use custom page-ids. Works like a charm. I rarely separate the AJAX calls out, owing to the single-threaded aspect of JS.
P.S: I had to use the term layers for lack of better alternative.
You can use an MVC on the browser too.
But it may be overkill.
The minimum you can do is to separate the HTML(view) and the JS(logic) code.
We use a javascript templating engine (PURE) for our JS app, but there are plenty of other available on the web.
jQuery and jQuery UI are a good start.
Have a look at JavaScriptMVC. It's an MVC framework for front end JavaScript applications. Version 2 is jQuery based so you'll get the power of that fantastic library into the bargain

ASP.NET MVC without MicrosoftAjax.js and MicrosoftMvcAjax.js

What parts of functionality will I lose after removing the
MicrosoftAjax.js
MicrosoftMvcAjax.js
files?
I don't want to use them for various reasons and I thought if there were any 3rd party helper methods that would mimic existing ones but are tied to another JavaScript framework, such as jQuery.
Also, please tell where usage of above javaScript files is preferrable/adviced.
Many thanks,
Valentin Vasiliev.
You won't be able to use the AjaxHelper extension methods (in the System.Web.Mvc.Ajax namespace) that are exposed by the Ajax property on the ViewPage class if you don't refer to the MicrosoftAjax scripts. They're relatively easy to replace by using the appropriate jQuery AJAX methods ($.post, $.get, $(selector).load etc) or the jQuery form plugin.
As for whether one or another is preferable or not it's down to how comfortable you are with writing your own implementation. The Ajax helper methods try to take care of a lot of things for you in terms of client script programming but that comes at a price of having to load in the pretty heavyweight MS AJAX library. Rolling your own javascript methods can lead to more lightweight code as well as providing you with a choice of javascript library to use (be it jQuery or one of the many others out there).
I agree. Just use jquery. Life is good with .net mvc 3.5 and jquery. cheers
You don't need those. Just remove them. Use JQuery instead.

Categories