I am trying to use jQuery’s $.getJSON() function to make a server-side AJAX call:
$.getJSON() {
url: "/my-server/some-url",
success: function() {
alert("Success!");
}
}
Firebug shows this as a JavaScript error:
SyntaxError: missing ; before statement
[Break On This Error]
$.getJSON() {
In reading the tutorial it appears that I’m using it right, passing in a URL and then a success callback. This particular URL doesn’t require any data parameters, so I omitted them. Can anyone spot where I’m going awrye? Thanks in advance!
You want to call a function, using the getJSON arguments:
Or use $.ajax passing an object:
To pass data (e.g.
{ dog: 1, cat: 4 }which will be converted to URL parameters) you can pass the object directly to both functions: