How to pass jQuery variable using AJAX to PHP page

Trying to pass variable "flickrurl" to PHP page using jQuery / ajax. It works when using a simple text string and not a variable. Am I assigning the variable correctly? See the complete 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 );

                }
            });

      

+2


a source to share


1 answer


JQuery AJAX functions expect data in JSON form. Try:



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

      

+5


a source







All Articles