使用JavaScript在.php中显示消息 [英] Displaying a message in .php using JavaScript

查看:66
本文介绍了使用JavaScript在.php中显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将记录插入MySQL数据库后,我想查看一条消息,表明不使用.php而是使用JavaScript成功添加了记录.我想这样做是为了在客户端(即Web浏览器)中查看消息.

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.

推荐答案

^ ]是你的朋友!

无论如何,您都必须在服务器端处理数据库交互,即使用PHP.

您将必须使用Javascript HTTP请求来调用数据库操作,并使服务器中的PHP代码在数据库中进行实际操作.之后,将结果作为普通的HTTP响应发送回客户端.然后,您可以使用Javascript向用户显示一个漂亮的小消息框.

但是,忘掉一切,然后阅读我给您的那个教程(当然,如果您不了解Ajax).然后您会找到一种解决方法.
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.


好朋友,我自己找到了解决方案.解决方案在底部提到.


echo''ja​​vascriptfunction(); ''

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


echo '' javascriptfunction(); ''

?>


这篇关于使用JavaScript在.php中显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆