显示加载图像的模式弹出扩展的Webservice的Ajax调用 [英] Showing Loading Image in Modal Popup Extender in Webservice ajax call

查看:96
本文介绍了显示加载图像的模式弹出扩展的Webservice的Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用阿贾克斯调用web服务mehod发送电子邮件至输入的电子邮件。

我想展示一个ajax模式弹出扩展containg图像说sendig ......

我用阿贾克斯打电话给我的web服务,如:

  VAR SendingModal = $发现('SendMPE');
    VAR重发= -1;
    $阿贾克斯({
             异步:假的,
             键入:POST,
             网址:FinKaynWebService.asmx / SendEmail
             数据:{电子邮件:+电子邮件+'},
             的contentType:应用/ JSON的;字符集= UTF-8,
             数据类型:JSON,
             beforeSend:函数(){
                 $(#SendMPE)显示()。
             },
             成功:函数(响应){
                 重发= response.d;
                 SendingModal.hide();
              },
              失败:功能(MSG){
                 警报(发送电子邮件失败,请稍后);
              }
    });
 

问题是,我SendMPE没有显示。

             

 < D​​IV ID =SendingDiv的风格=显示:无;背景色:黄色;颜色:蓝色;>
     < IMG ID =LoadingImageALT =尚派SRC =./图像/ Sending.gif/>
    <跨度风格=保证金左:10px的;>发送...< / SPAN>
    < ASP:按钮的ID =CloseButton=服务器的风格=显示:无; />
< / DIV>
< ASP:ModalPopupExtender ID =SendMPEX =200Y =200=服务器
                    的TargetControlID =SendHiddenButtonPopupControlID =SendingDiv
           CancelControlID =CloseButton>< / ASP:ModalPopupExtender>
 

这是这个问题造成的图像还是什么?

谁有想法或已经做好somthin这样的:在一个popoup加载图片

解决方案

首先,你应该使用

 数据:{电子邮件:'+电子邮件+}
 

或更好

 数据:JSON.stringify({电子邮件:电子邮件})
 

而不是

 数据:{电子邮件:+电子邮件+'}
 

看<一href="http://stackoverflow.com/questions/5119977/jquery-ajax-response-always-returns-nothing/5127142#5127142">this回答获取详细信息。

还有一个的话。本次活动 beforeSend(jqXHR,设置)应使用修改jqXHR(jQuery的1.4.x的,XMLHTT prequest)在发送对象之前(见的 jQuery.ajax documantation)。你的情况,你可以只把 $(#SendMPE)显示(); $阿贾克斯之前调用。

另外可能​​是你想要使用 $(#SendingDiv)显示();?

I use .ajax to call a webservice mehod that sends an email to entered email.

I want to to show an ajax modal popup extender containg an image saying 'sendig...'

i used .ajax to call my webservice like:

var SendingModal = $find('SendMPE');
    var Resend = -1;
    $.ajax({
             async: false,
             type: "POST",
             url: "FinKaynWebService.asmx/SendEmail",
             data: "{'Email': '" + Email + "'}",
             contentType: "application/json; charset=utf-8",
             dataType: "json",
             beforeSend: function() {
                 $("#SendMPE").show();
             },
             success: function(response) {
                 Resend = response.d;
                 SendingModal.hide();
              },
              failure: function(msg) {
                 alert('Sending Email failed,try later');
              }
    });

the problem is that my SendMPE is not showing.

<div id="SendingDiv" style="display:none;background-color:Yellow;color:Blue;">
     <img id="LoadingImage" alt="Still sending"  src="./Images/Sending.gif" />
    <span style="margin-left:10px;">Sending...</span>
    <asp:Button ID="CloseButton" runat="server" style="display:none;" />
</div>
<asp:ModalPopupExtender ID="SendMPE" X="200" Y="200" runat="server" 
                    TargetControlID="SendHiddenButton" PopupControlID="SendingDiv" 
           CancelControlID="CloseButton"></asp:ModalPopupExtender>

is this this problem caused by the image or what?

Who has an idea or has already done somthin like that:loading image in a popoup.

解决方案

First of all you should use

data: '{"Email": "' + Email + '"}'

or better

data: JSON.stringify({Email: Email})

instead of

data: "{'Email': '" + Email + "'}"

see this answer for details.

One more remark. The event beforeSend(jqXHR, settings) should be use to modify jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent (see jQuery.ajax documantation). In your case you can just place $("#SendMPE").show(); before the $.ajax call.

Moreover probably you want use $("#SendingDiv").show();?

这篇关于显示加载图像的模式弹出扩展的Webservice的Ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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