What do the {and} internal parameters mean?

Let's take an example:

$.ajax({lhs:val});

What does it do {}

? As far as I know, there are no named parameters - is this the actual member (same as $.ajax.lhs

)? What does this mean and what does it do?

+2


source to share


4 answers


It is a literal for an object.



var anObject = { member1: "Apple",
                 member2: function() { alert("Hello"); } };

alert(anObject.member1);      // Apple
anObject.member2();           // Hello

      

+5


source


It is an object literal notation. It creates an object with the property lhs

set to val

.

This is another way to do the following



var obj = new Object();
obj.lhs = val;
$.ajax(obj);

      

In jQuery, many functions take an options object, which is just a regular object with various properties set to define how the function acts.

+7


source


This is an object literal (better known as a JSON object):

JSON (JavaScript Object Notation) is a lightweight data interchange format. It is easy for a person to read and write. Easy for machines to analyze and generate. It is based on a subset of the JavaScript Programming Language, ECMA-262 Standard 3rd Edition - December 1999. JSON is a text format that is completely language independent, but uses conventions that are familiar to programmers of the C-family of languages, including C, C ++, C #, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data interchange language.

+5


source


This is an anonymous object literal. In a basic sense, think of it as an associative array that uses "words" instead of number indices.

In your case, you are sending this object as the first (and only) parameter of the ajax method.

0


source







All Articles