[jQuery] Getting PHP values remotley

[jQuery] Getting PHP values remotley


Hello, I was wondering how to get a value from a php file after I send
data to it using the $.ajax() method. Here's my code.
jQuery:
var path = $(this);
var addtask = $('.inputtask').val();
    $.ajax({
        url: 'todolistadd.php',
        data: 'addtask= ' + addtask,
        success: function() {
            // Stuff
        }
    });
PHP:
    $addtask = $_POST['addtask'];
    $q = "INSERT INTO task (tasks) VALUES ('$addtask')";
    $ans = mysql_query($q);
    $q = "SELECT task_id FROM task WHERE tasks = '$addtask' LIMIT 1";
    $newid = mysql_query($q);
What I want from the php file is the $newid value to use in the
previous script, any help or suggestion will be greatly appreciated.
Thanks