Skip to content

Instantly share code, notes, and snippets.

@jansabbe
Created June 5, 2011 19:00
Show Gist options
  • Save jansabbe/1009277 to your computer and use it in GitHub Desktop.
Save jansabbe/1009277 to your computer and use it in GitHub Desktop.
Example calling json webservice with jQuery
var jsonData = JSON.stringify({
stad: 'Leuven',
soort: 'KLEI',
telefoonNummer: '141414'
});
$.ajax('/plaatsen', {
success:function (data) {console.log(data)},
type: 'PUT',
dataType: 'json',
data: jsonData
});
$.ajax('/plaatsen', {
success:function (data) {console.table(data)},
type: 'GET'
});
$.ajax('/plaatsen/1', {
success:function (data) {console.log(data)},
type: 'GET'
});
$.ajax('/plaatsen/1/metingen', {
success:function (data) {console.table(data)},
type: 'GET'
});
var jsonData = JSON.stringify({
datum: new Date(),
longitude: '42',
latitude: '4',
phWaarde: 8,
commentaar: 'geen commentaar'
});
$.ajax('/plaatsen/1/metingen', {
success:function (data) {console.log(data)},
type: 'PUT',
dataType: 'json',
data: jsonData
});
$.ajax('/plaatsen/1/metingen', {
success:function (data) {console.table(data)},
type: 'GET'
});
$.ajax('/plaatsen/1/metingen/1', {
success:function (data) {console.log(data)},
type: 'GET'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment