Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript XHTML PHP , +
After inserting a record to a MySQL database I want to view a message that the record adding is successful by not using .php but using JavaScript. I want to do that to view the message in the client's side i.e the web browser.
Posted 22-Feb-12 22:01pm
Comments
SAKryukov at 23-Feb-12 3:18am
   
Why? How Javascript can know your MySQL data? Do you really understand what Javascript does? I'm not sure.
--SA
Chiranthaka Sampath at 23-Feb-12 6:09am
   
After insert one record gives '1 record added' message in php. But I want to display that message like a message box using javascript(an alert).
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Ajax[^] is your friend!
 
No matter what, you will have to handle the database interactions in the server side, i.e. using PHP.
 
You will have to invoke the database operation using a Javascript HTTP request, and make the PHP code in server do the real operation in the database. After that, send the result back to the client as the normal HTTP response. And then you can display a nice little message box to the user using Javascript.
 
But, forget everything and read that tutorial I gave you, (if you don't know about Ajax, of course). And you'll find a way doing it then.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Ok pals I got the solution by my self. The solution is mentioned at the bottom.
 

echo '<script> javascriptfunction(); </script>'
 
?>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 290
1 OriginalGriff 275
2 Sergey Alexandrovich Kryukov 195
3 BillWoodruff 140
4 ProgramFOX 140
0 OriginalGriff 6,524
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,218
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 23 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100