How to pass multiple JavaScript data variables in a jQuery ajax() call? How to pass multiple JavaScript data variables in a jQuery ajax() call? ajax ajax

How to pass multiple JavaScript data variables in a jQuery ajax() call?


Try:

data: {    start: startDateTime,    end: endDateTime}

This will create request parameters of 'start' and 'end' on the server that you can use.

The {...} is an object literal, which is an easy way to create objects. The .ajax function takes the object and translates its properties (in this case, 'start' and 'end') into key/value pairs that are set as properties on the HTTP request that gets sent to the server.


data: {    startDateTime : "xxx",    endDateTime : "yyy"}


You can pass the values in JSON notation:

data: {startDateTime: 'value here ', endDateTime: 'value here '}