Created
February 9, 2012 18:18
-
-
Save zclancy/1781761 to your computer and use it in GitHub Desktop.
Updated sametime_invoke using jQuery/AJAX/callback functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Instant = {}; | |
Instant.launchSametimeConversation = function (stid) { | |
var time = new Date(); | |
var getUrl = 'http://localhost:59449/stwebapi/chat?userId=' + stid + '&time=' + time.getTime() + '&jsonp=Instant.handleResponse'; | |
// Use jQuery to request the Sametime servlet URL. If a request makes it to the URL successfully, the servlet will return a code 200 and open the Sametime client chat with the user. | |
// We use the Instant.handleResponse() function as a callback to process the JSONP data object that the servlet hands back. | |
$.ajax({ | |
type: 'GET', | |
url: getUrl, | |
dataType: 'jsonp', | |
jsonpCallback: 'Instant.handleResponse' | |
}); | |
}; | |
// A rudimentary callback function to handle JSONP data objects retrieved by the Instant.launchSametimeConversation() function. | |
Instant.handleResponse = function (data) { | |
if (data.returnCode === 200) { | |
alert('Success!'); | |
} else { | |
alert('Failed!'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment