Show as Ajax in Bootstrap Modal

Asked 1 years ago, Updated 1 years ago, 68 views

I would like to see what was called in phpfile.php in .modal-body of #mymodal, but the following code does not work.
The modal comes out, and if it's not ajax, it will appear, so you can't load the page into the modal...

function addCart(id){
    $('#mymodal.modal-body') .load("phpfile.php", $("#"+id).serialize(), function(){
        $('#mymodal').modal('show');
    });

I would appreciate it if someone could point it out.

javascript ajax twitter-bootstrap

2022-09-30 20:11

1 Answers

If phpfile.php is receiving form control data at POST, I think phpfile.php will not return the result data unless the object is passed by the second argument instead of the string. (.serialize() will return the string, so it will be passed by GET).

The following is an example of object passing (POST transmission)

$('#hoge.fuga') .load("piyo.php", {data1:1, data2:2}, function(data){console.log(data)});


2022-09-30 20:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.