简体   繁体   English

使用Jquery插入和选择数据

[英]Inserting and selecting data using Jquery

I am working with visual studio 2010,4.0 frame work my pages are like the following 我正在使用Visual Studio 2010,4.0框架工作我的页面如下

default.aspx contain a textbox button default.aspx包含一个文本框按钮

on the click of button the data should insert into the sql database without the page being posted ie using jquery. 单击按钮后,数据应插入到sql数据库中,而无需发布页面,即使用jquery。

How can it be done? 如何做呢?

Make use of jquery ajax function will do task for you.... 利用jquery ajax函数将为您完成任务。

Example: 例:

Jquery Ajax Calling functions jQuery Ajax调用函数

Steps to Call WCF Service using jQuery 使用jQuery调用WCF服务的步骤

On click of the button you can make Ajax call using jQuery, which will update your table. 单击该按钮后,您可以使用jQuery进行Ajax调用,这将更新您的表。 For this on your server you will need either PageMethods or some web service, which jQuery will call. 为此,您需要在服务器上使用PageMethods或jQuery将调用的某些Web服务。

Using PageMethods 使用PageMethods

JavaScript 的JavaScript

$("#button").click(function(e){
    PageMethods.GetData(OnGetComplete);
});  

function OnGetComplete(result, userContext, methodName) {
     //Handle Result
} 

Code Behind 背后的代码

[WebMethod]
public static string GetData() {     
    return "Some random data";
}          

For WCF and JQuery you can see the answer by Pranay Rana. 对于WCF和JQuery,您可以看到Pranay Rana的答案。 Hope this helps you. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM