如何在鼠标悬停功能上调用webservices [英] how to call webservices on mouse hover functioin

查看:56
本文介绍了如何在鼠标悬停功能上调用webservices的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家..

我创建了一个Web服务..它正在从数据库中获取数据..现在我必须在鼠标悬停时刷数据..但我无法调用鼠标悬停时的服务

Hi Experts ..
I have created a web services ..which is fetching data from database ..Now I have to shoe data on mouse hover ..but I am not able to call the services on mouse hover

[WebMethod]
       public DataSet GetData()
       {
       if(cn.State==ConnectionState.Closed)
          {
              cn.Open();
          }

       SqlDataAdapter da = new SqlDataAdapter("select  notes_note,c.cand_fname + ' ' + cand_lname as name, n.notes_createddate,c.cand_id_pk from tb_notes n,tb_candidate_go_beta c where n.notes_about_id=c.cand_id_pk ", cn);
       DataSet dt = new DataSet();
       da.Fill(dt);
       return dt;
       cn.Close();
       }



现在我在鼠标悬停时调用了这项服务..我怎么做...请帮助


Now i have call this services on mouse hover ..How i can do this ...please help

推荐答案

你可以在jquery的帮助下简单地叫你web服务。以下是您的样本系数。



you can simply call you web service with the help of jquery. Here is the sample coe for you.

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript">



    function abc()
    {


.ajax({
类型:POST,
contentType:应用/ JSON; charset = utf-8,
url:Webmethod.aspx / BindDataToDropDown,
data:{},
dataType:Json,
success:function(数据){
//当你成功执行web方法时调用这个函数。
//编写从web方法返回的绑定数据的代码。


})
}
});
}
< / script >
.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "Webmethod.aspx/BindDataToDropDown", data: "{}", dataType: "Json", success: function (data) { // this function is called when you web method executed sucessfully. // write code for binding data returned from web method. }) } }); } </script>





只需调用函数abc( )在鼠标悬停事件的控件上它将调用Web服务。







Just simply call the function "abc()" on mouse hover event of the control it will the call the web service.


<img onmouseover="abc()" border="0" src="smiley.gif" alt="Smiley" width="32" height="32">

您好,



添加 jQuery [<小时ef =https://developers.google.com/speed/libraries/devguide#jquery\"target =_ blanktitle =新窗口> ^ ]在您的网页上使用jQuery,您可以在这样:
Hi,

Add jQuery [^] on your page and using jQuery you can acheive this in this way:


这篇关于如何在鼠标悬停功能上调用webservices的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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