Sir/MAAM
The code(js file) in public/addnew folder name of file addnew.js i am trying to append the data given by the server but its not happening
Its the only problem
link-> https://github.com/Rahul172000/MYSQL-in-SERVER
Check my code repo link is given
pls tell the reason coz of which the data is not appended
On line 10 of server.js, you are sending a string indicating succesful add. Instead, you must send back a json with the new data. This will be received by addnew.js file, and will be appended to the list.
But sir in file addnew.js when I am doing console.log(‘test’) inside click function even that is not printed on console, when I click the submit button the test comes for a second and then disappears… Why so?? And in another code I sent the string in res.send it was working but why not in this??
Thats because after $.post, the page refreshes. To avoid refreshing the page, return false
from the function.
Return false from where??
sir please check this code,its with same approach and its working fine i mean the problem with the previous is not occurring in this one though everything is same
Remove the <a>
tag around your Add button. That <a>
tag is causing to refreshing the page whenever you click it, thats why you cant see the response.
Thank you sir
I saved that a tag for later but then forgot to removed it