Copy codeThe Code is as follows: using jquery ajax call wcf service get/post/put/delete
Http://www.codeproject.com/Articles/254714/Implement-CRUD-operations-using-RESTful-WCF-Servic
Using POST Method
Retrieve a representation of the addressed member of the collection, in the example below, create a new entry in the collection.
Collapse | Copy Code
$. Ajax ({
Type: "POST ",
Url: "Services/EFService. svc/Members /",
Data: "{Email: 'test @ test.com ', ScreenName: 'testuser '}",
ContentType: "application/json; charset = UTF-8 ",
DataType: "json ",
Success: function (data) {// Play with response returned in JSON format },
Error: function (msg ){
Alert (msg );
}
}); Using PUT Method
Update the entire collection with another collection, in the example below, update the addressed member of the collection.
Collapse | Copy Code
$. Ajax ({
Type: "PUT ",
Url: "Services/EFService. svc/Members /",
Data: "{Email: 'test @ test.com ', ScreenName: 'testuser '}",
ContentType: "application/json; charset = UTF-8 ",
DataType: "json ",
Success: function (data) {// Play with response returned in JSON format },
Error: function (msg ){
Alert (msg );
}
}); Using DELETE Method
Delete the entire collection or a specific collection, in the example below, delete Member with id = 1.
Collapse | Copy Code
$. Ajax ({
Type: "DELETE ",
Url: "Services/EFService. svc/Members (1 )",
Data :"{}",
ContentType: "application/json; charset = UTF-8 ",
DataType: "json ",
Success: function (data) {// Play with response returned in JSON format },
Error: function (msg ){
Alert (msg );
}
});