1

I want to create a alert box after user presses the delete button if he press ok after that the row should be deleted. i tried to use alert in my app.js file but it is showing alert is not defined. does this have any solution.

  • 1
    I think you're trying to use a browser's `alert()` function in a server-side node.js application. – Aioros Jan 17 '19 at 19:14
  • Probably relevant: https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming – Quentin Jan 18 '19 at 09:48
  • Could you show your code ? In general, for debugging questions, the relevant code is expected, this often clarifies the problem a lot, and allows for quicker and more precise answers. See also [mcve], and [Writing the perfect question](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) – Pac0 Jan 18 '19 at 12:33

2 Answers2

1

node.js is backend (server side) javascript and alert is supported in UI javascript. you can use console.log(data) in node.js to check result in node.js.

Mudassir
  • 578
  • 4
  • 6
0
  1. User press Delete
  2. Show popup with Ok/Cancel

    <div>
        Do you want to delete?
        <div id="ok-button">OK</div>
        <div>Cancel</div>
     </div>
    

<script> $("#ok-button").on("click",function(){ $.ajax({ url: my_url, type: "POST", dataType: "json", data: {id : "id_to_delete"}, contentType: "application/json" }).done(function(notification_from_server) {alert(notification_from_server);}); }); </script>

  1. If user press Ok, do ajax call to server that do DB things
  2. Ajax call have call back for showing "Item has been deleted" notification when it is done.
maximelian1986
  • 2,308
  • 1
  • 18
  • 32