是否有可能显示来自Web服务的弹出 [英] Is it possible to show a PopUp from a web service

查看:140
本文介绍了是否有可能显示来自Web服务的弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Asp.Net 4.0

Asp.Net 4.0

在我的网站applicaion我使用的Web服务方法。是否有可能显示一个弹出到来自用户从在web服务的方法请求信息?

In my web applicaion i'm using web service methods. Is it possible to show a popup to request information from a user from a method in the web service?

推荐答案

如果没有你调用的Web服务的更多细节,我会给你一个很普通的例子。它需要jQuery的。

Without further details about the web service you are invoking, I will give you a quite general example. It requires jQuery.

它假定Web服务是由客户端的一些触发调用:它可能是一个用户事件(点击,按键preSS)或DOM事件(负载,准备)。处理程序被分配给该事件。在按钮单击事件的话,那么:

It assumes that the web service is invoked by some trigger in the client: it could be a user event (click, key press) or a DOM event (load, ready). A handler is assigned to this event. In the case of a button-click event then:

$('#btnCallService').bind('click'
    , {dataObject: 'add evet related data here'}
    , function(event){
        /* here a handler is executed when btnCallService is clicked  */
        callServiceHandler(event.data)
    }
);

下面是处理程序的主体,与该呼叫到服务

Here is the body of the handler, with the call to the service.

function callServiceHandler(eventData) {
    $.ajax({
        type: "GET",
        url: "url_to_your_service_method",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: yourWebMethodArguments,
        success: function (resultData) {
            /* everything is right! result data are available for client side processing and rendering */

            alert('Request completed!');
        }
        error: function (req, status, message) {
            /* something is wrong: guide the user */
            alert('Unable to execute your request: \n' + message);
        },

    });
}

正如你所看到的,Web方法调用没有弹出可言。你可以集中处理程序库中,并从您的网站,每一个地方调用它。

As you can see, the web method calls no popup at all. You could centralize the handler in a library, and call it from every where in your site.

这篇关于是否有可能显示来自Web服务的弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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