开发者

How to pass jQuery variable with AJAX to PHP page

开发者 https://www.devze.com 2022-12-30 03:50 出处:网络
Trying to pass the variable\"flickrurl\" to a PHP page with jQuery/ajax. It works when using a plain text string and not the variable. Am I assigningthe variable properly?See the full code in action h

Trying to pass the variable "flickrurl" to a PHP page with jQuery/ajax. It works when using a plain text string and not the variable. Am I assigning the variable properly? See the full code in action here:

$trash.droppable({
                accept: '#gallery > li',
          开发者_运维问答      activeClass: 'ui-state-highlight',
                drop: function(ev, ui) {
                    deleteImage(ui.draggable);
                                //set variable equal to src of image tag in #gallery > li
                        var  $flickrurl =  $item.find('img').attr("src");
                //pass variable to php page
                      $.post("updateDB.php", $flickrurl );

                }
            });


jQuery's AJAX functions expect data in JSON form. Try:

$.post("updateDB.php", { 'flickrurl': $flickrurl } );
0

精彩评论

暂无评论...
验证码 换一张
取 消