user618879
user618879

Reputation: 319

Cannot save data from pop window to database

I have a screen from which a user can click on a button that brings up a popup window. When the user clicks on save from the pop up window, the data is to be save. It doesn't save anything, it is as if it does not see the database. This cannot be because I'm able to call data from it and display it.

jQuery on user page:

$(".up").click(function(){
    var code = '1234';
    var id = '24';
    var who = 'someone';
    $("#ui").html('loading...').show();
var url = "box.php";
    $.post(url, {code: str, g:id, u:who} ,function(data) {
        $("#ui").html(data).show();
    });
});

php on popup bx:

//link db  {...........}
// grab post
$click = $_POST[code];
$id = $_POST['g'];
$u = $_POST['u'];

// query php {........}

jQuery on popup box:

$("#process").click(function(){
    var ID = '24';
    var who = "someone";
    var pla = "place";
    $.ajax({
        type: "POST",
        url: "member.php", //contains function 
        data: 'user='+ who+ '&dept='+ pla+ '&sure='+ ID, 
        cache: false,
        success: function(html) {   
            //do something
        }
    });
});

When I hit submit it doesn't post to the database. Maybe it's not passing the data to the member.php page.

Upvotes: 0

Views: 537

Answers (1)

snuffn
snuffn

Reputation: 2122

Try to change:

$('#process').click(function()
{
    ...
});

to:

$(document).on('click','#process',function()
{
    ...
});

Edit:

BTW, you also need to change:

$click = $_POST[code];

to:

$click = $_POST['code'];

Maybe you should also take a look at jQuery's serialize() function, which will make it easier for you to get all your form values passed to your Ajax request.

For more information: http://api.jquery.com/serialize/

Upvotes: 1

Related Questions