0

Hi my first time here asking a stupid question. :) I'm building a simple site where you can add edit delete tasks to do and complete them.

I'm done with the most of it, just the complete part is messing with me.

Its a button, then pressed it sends a json put request to the api, that saves it to the mySQL database. The data is the time when completed and just a check. I don't know how to send the time part. :(

$wTasks.delegate('.finish', 'click', function()
    {
        var $li = $(this).closest('li');
        var finito = 
            {   
                end_date: date("Y-m-d h:i:s"),
                end_check: 1,
            }

        $.ajax(
        {
            type: 'PUT',
            url: 'api.php/tasks/' + $(this).attr('data-id'),
            data: finito,
            success: function()
            {   

            }

        });
    })

date() doesn't work here. And I don't know what to use

SlaShX
  • 9
  • 2
  • 1
    What do you mean by "The data is the time when completed and just a check"? You might want to take a look at this one: http://stackoverflow.com/questions/19448436/how-to-create-date-in-yyyymmddhhmmss-format-using-javascript – ThatMSG Dec 23 '15 at 19:39
  • 1
    Why do you need to send the date? You can get it on the server instead. Unless you also need the time-zone of the user of course. – jeroen Dec 23 '15 at 19:41
  • https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date also you need to serialize `finito` for it to be json – Musa Dec 23 '15 at 19:42
  • The data sent with json. That is used to know if the task is completed and when. – SlaShX Dec 23 '15 at 19:42
  • Are you sure you want to use `PUT` versus `POST`? Also you need to make a Date object. See more: http://www.w3schools.com/jsref/jsref_obj_date.asp – Twisty Dec 23 '15 at 19:48

0 Answers0