Topic: Calling PHP script from drag and drop REMOVE BUTTON

rt133813 pro asked 5 years ago


I want to call a PHP script when the drag and drop REMOVE button is clicked to  update my database.  I understand the PHP is my responsibility, and that's not a problem.  I am not so strong in JS,  but have looked at all files in the drag and drop plugin file structure.  I understand where all the files are at, but what JS or CSS file do I modify, the JS is a bit overwhelming for my skill level.  If you can help me with this, here is how I picture it working.  When the user clicks the REMOVE button, it will call a PHP script that will delete the image path from my database table, then return to a specific page.  NOT the drag and drop page.  Obviously if there is no image to begin with, it will still return to the page that called the drag and drop function.  If this is to much effort, then how can I remove the "REMOVE" button all together, then I will call my PHP script from a button outside the image canvas.  I would be happy either way.  Thanks for any help!

rt133813 pro answered 5 years ago


Thanks for that info Ania.  I have not tried it, but will keep it in my toolbox as I already did it a different way.  But I always like to say thank you to the folks that try to help me :)


Anna Morawska staff commented 5 years ago

Thank you, it's an awesome approach,  it's nice to hear :)  Happy coding


Anna Morawska staff answered 5 years ago


Hi there! 

You can call a PHP function from JS using ajax calls - you can find plenty of resources on the internet, please check it out. If you will have any futher questions, just ask here :)

In general, it should look something like this: 

$('.mdb-upload .btn-danger').on('click', function(){
jQuery.ajax({
type: "POST",
url: 'your_functions_address.php',
...
})

Best,

Ania



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.5.10
  • Device: All
  • Browser: All
  • OS: All
  • Provided sample code: No
  • Provided link: No
Tags