11

If startDateTime & endDateTime have are dateTime values along the lines of this:

Start: Mon Jan 10 2011 18:15:00 GMT+0000 (GMT Standard Time)
End: Mon Jan 10 2011 18:45:00 GMT+0000 (GMT Standard Time)

How do you pass both startDateTime & endDateTime to the ajax call below?

eventNew : function(calEvent, event) 
{
    var startDateTime = calEvent.start;
    var endDateTime = calEvent.end;
    jQuery.ajax(
    {
        url: '/eventnew/',
        cache: false,
        data: /** How to pass startDateTime & endDateTime here? */,
        type: 'POST',
        success: function(response)
        {
            // do something with response
        }
    });         

},

6 Answers 6

12

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

3

You can pass the values in JSON notation:

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

Comments

1

Try it:

data: JSON.stringify({ start: startDateTime, end: endDateTime })

Comments

0
ajax({
     url : //your file url finshed with ,
     data : {
         Start: Mon Jan 10 2011 18:15:00 GMT+0000 (GMT Standard Time),
         End: Mon Jan 10 2011 18:45:00 GMT+0000 (GMT Standard Time)
     },
     type: 'POST',
     success: function(response) { 
         // do something with response 
     }
});

Comments

0

in the data

ajax({
    url : //your file url finshed with **,**
    data : {Start: Mon Jan 10 2011 18:15:00 GMT+0000 (GMT Standard Time),
           End: Mon Jan 10 2011 18:45:00 GMT+0000 (GMT Standard Time)}, //finish with **,**
    type: 'POST',
    success: function(response)
    {
        // do something with response
    }

});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.