Insertion, editing, removal and visualization of data

Asked

Viewed 49 times

2

I have a CRUD in PHP developed with the MVC standard, all interaction with the database is performed with PDO, my challenge is, pass all data requests asynchronously using Ajax and Json. I have only theoretical knowledge about asynchronous requests and would like to know how best to make this change? there is some framework that can be performed?

Thank you!

1 answer

0


You can use Jquary to help with your asynchronous requests. With a simple code like this below you can make an asynchronous request.

$.ajax({
    url: "demo_test.txt",
    method: "GET",
    data: { name: "John", location: "Boston" },
    success: function(result){
        console.log(result);
    }
});
  • Hello Phelipe, my main doubt is how to pass on this information following the MVC standard

  • Using AJAX you will already be preserving the MVC structure. Everything you have printed in your PHP code will be in the result variable. So, assuming you want to print a table for example, you can mount a json in your back-end, retrieve that information by the result variable in your javascript, and then do what you want with it. Javascript offers a complete range of tools to handle the DOM, so you can manipulate your page by completely separating front-end and back-end

  • I think I understand the idea of the process, I will try to implement in the code and, if necessary, I return the question. Thank you very much for helping Phelipe!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.