如何在ASP.NET 2.0中使用JavaScript插入数据库

问题描述:

大家好

我是javascript的新手,我想使用javascript将数据插入数据库.
请帮助.

amit jamwal

hi to all

I am new to javascript and i want to insert data to my database using javascript.
plz help.

amit jamwal

您想知道如何与Java脚本进行通信(将数据推入数据库的服务器).

通过客户端(Javascript)与服务器端进行交互的方法很少:
1. XMLHttpRequest [回调 [ Web服务调用 [ PageMethod [
You want to know how to talk to server(where you will push data to database) from Javascript.

There are few ways to interact with server side through client side(Javascript):
1. XMLHttpRequest[^]
2. Callback[^]
3. WebService call[^]
4. PageMethod[^]

Pick one that suits you and implement it.


您可以使用ajax将数据推送到数据库.
jQuery简单实用.


you can use ajax ,push data to database.
jquery is simple and useful.



.post(' test.ashx ',{parm:value},功能(返回){ // 做某事 }," );
.post('test.ashx', { parm:value },function (back) { //do something }, "json");



test.ashx代码:



test.ashx code:

context.Response.ContentType = "application/json";
context.Response.Write("{\"p\":\"11\",\"s\":\"22\"}");