Tuesday, August 4, 2009

Webservice Easy to implement using JQuery.

An iMIS Tips and Tricks by Venketesh Subramony
Consultant, BroadPoint Technologies

The jQuery code is very simple and easy to learn.

Here are the features of jQuery

1. DOM element selections functions

2. DOM traversal and modification

3. Events

4. CSS manipulation

5. Effects and animations

6. Ajax

7. Extensibility

8. Utilities - such as browser version and the each function.

9. JavaScript Plugins

POST Method

function InfoByDate(sDate, eDate){
var divToBeWorkedOn = '#AjaxPlaceHolder';
var webMethod = 'http:// WebService/Web.asmx/GetInfoByDates'
var parameters = "{'sDate':'" + sDate + "','eDate':'" + eDate + "'}"
$.ajax({
type: "POST",
url: webMethod,
data: parameters,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$(divToBeWorkedOn).html(msg.d);
},
error: function(e){
$(divToBeWorkedOn).html("Unavailable");
}
});


GET Method

$.get("http://doman.com/webservice.asmx", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);
});

No comments:

Post a Comment

Add this

Bookmark and Share