how do i update/populate my select input after insert data without refresh page?

how do i update/populate my select input after insert data without refresh page?

EricDEricD Posts: 11Questions: 0Answers: 0

Hello,

how do i update/populate my select input after insert data without refresh page?

Thanks

Replies

  • kthorngrenkthorngren Posts: 21,144Questions: 26Answers: 4,918

    Please provide more details of what you are doing.

    How are you inserting data?

    Where are the selects and what are they used for?

    Maybe you can post a link to your page or a test case so we can see exactly what you are doing.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • EricDEricD Posts: 11Questions: 0Answers: 0

    Hi Kevin,

    Sorry, i had to create another free webhost

    https://kennelz.000webhostapp.com/pets.php

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Your link says "502 Bad Gateway".

  • EricDEricD Posts: 11Questions: 0Answers: 0

    Aww, not possible, im online now and website working fine

  • EricDEricD Posts: 11Questions: 0Answers: 0
    edited April 2019

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @EricD ,

    This blog post may help, as it's showing how the table can be updated before an edit. The same logic could apply to your scenario.

    Cheers,

    Colin

  • EricDEricD Posts: 11Questions: 0Answers: 0

    Thanks for reply, i ended up with this solution, idk if a good idea, because i have to reload ajax all time

    success: function () {
    $("#pets").DataTable().ajax.reload(null, false );
    }

    Now i want to order by 'name', how do i do it, since we dont have [->order] in server side

    https://kennelz.000webhostapp.com/dogs.php

    if you get 502 badgateway, can you check with another browser please

    Thank you

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @EricD ,

    If the data is likely to change, you would need to request from the server each time, as in the example I linked to before. If it's static, you could just do when the table initialises.

    Cheers,

    Colin

This discussion has been closed.