如何存储从Ajax函数返回的值 [英] How Do I Store A Value Returned From A Ajax Function

查看:58
本文介绍了如何存储从Ajax函数返回的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我目前正在使用Ajax将数据发布到vb.net中的网络服务



我的代码运行良好,直到成功功能(r)



我需要将数据发布到网络服务并返回另一个值

请可以你协助



这里是我的代码ajax



Hi
I am currently using Ajax to post data to a web service in vb.net

My code runs all well up until the the success function(r)

I need to post data to the webservice and return another value
Please could you assist

here is my code for the ajax

var selectedFields = ($('#result').val());
            var Qid = '<%=Session("Qid")%>';
            var DrawnName= document.getElementById('<%=DrawnName.ClientID%>').value;
 var Uid = document.getElementById('<%=HiddenField1.ClientID%>').value;







$.ajax({

               url: 'Drawn.aspx/SelectedPoints',
               data: "{ 'selectedFields': '" + selectedFields + "','Qid':'" + Qid + "','DrawnName':'" + DrawnName + "','Uid':'" + Uid + "'}",
               dataType: "json",
               type: 'POST',
               contentType: 'application/json; charset=utf-8',



               success: function (r) {
                   //debugger;
                   alert(r.d.val);
                   var RID = r.d.value
                   alert(RID)
                
                   {
                   // }
               }

           });







如果我在firefox中使用firebug我可以在响应中看到正确的值

例如d:68



如何将变量变为var?




if i firebug in firefox i can see under the response the correct value
e.g"d: 68"

how do i get that variable into a var?

推荐答案

' #result')。val());
var Qid = ' <%=会话( 脉冲Qid)%>';
var DrawnName = document.getElementById(' <%= DrawnName.ClientID%>')。 value ;
var Uid = document.getElementById(' <%= HiddenField1.ClientID%>')。 value ;
('#result').val()); var Qid = '<%=Session("Qid")%>'; var DrawnName= document.getElementById('<%=DrawnName.ClientID%>').value; var Uid = document.getElementById('<%=HiddenField1.ClientID%>').value;








.ajax({

url:' Drawn.aspx / SelectedPoints'
data: {'selectedFields':' + selectedFields + ','Qid' :' + Qid + ','DrawnName':' + DrawnName + ','Uid':' + Uid + '}
dataType: JSO n
类型:' POST'
contentType :' application / json; charset = utf-8'



成功:功能(r){
//调试器;
alert(r.d.val);
var RID = rdvalue
alert(RID)

{
//}
}

});
.ajax({ url: 'Drawn.aspx/SelectedPoints', data: "{ 'selectedFields': '" + selectedFields + "','Qid':'" + Qid + "','DrawnName':'" + DrawnName + "','Uid':'" + Uid + "'}", dataType: "json", type: 'POST', contentType: 'application/json; charset=utf-8', success: function (r) { //debugger; alert(r.d.val); var RID = r.d.value alert(RID) { // } } });







如果我在firefox中使用firebug我可以在响应中看到正确的值

例如d:68



如何将变量变为var?




if i firebug in firefox i can see under the response the correct value
e.g"d: 68"

how do i get that variable into a var?


success: function (r) {
    //debugger;
    var RID = r.d;
    alert(RID)
   }


这篇关于如何存储从Ajax函数返回的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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