How to send multiple values using ajax to PHP How to send multiple values using ajax to PHP ajax ajax

How to send multiple values using ajax to PHP


You can pass multiple key / value pairs to PHP as an object in $.ajax

$.signuser = function () {    FB.api('/me', function (response) {        var data = {     // create object            fbfname    : response.first_name,            fblname    : response.last_name,            fblname    : response.id,            fblink     : response.link,            fbusername : response.username,            fblink     : response.email        }        $.ajax({            type: "POST",            data: data, // pass as data            url: "fbpost.php"        }).done(function (feedback) {            $('#fg').html(feedback)        }).always(function() {            $('#booksloadjif').css('display','none')        });    });}

and you'd access them in PHP with

$_POST['fbfname'] $_POST['fblname'] 

etc, i.e. the keynames in javascript are also the key names for the $_POST array