从ASPX.cs到JavaScript的数据 [英] Data from ASPX.cs to JavaScript

查看:77
本文介绍了从ASPX.cs到JavaScript的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.net项目中,我可以使用

In an ASP.net project, I can retrieve the data from a webservice using

var webClient = new System.Net.WebClient();
string data = webClient.DownloadString(url);



然后我尝试使用jQuery的$ .ajax()做同样的事情,但没有成功。我想知道是否有可能将从.aspx.cs获得的数据传递给.aspx中的javascript。如果你能提示我,请提前感谢。


Then I tried to use jQuery's $.ajax() to do the same thing, but not successful. I wonder if it is possible to pass the data obtained from the .aspx.cs to the javascript in the .aspx. Thanks in advance if you can hint me.

推荐答案

.ajax()做同样的事情,但没有成功。我想知道是否有可能将从.aspx.cs获得的数据传递给.aspx中的javascript。如果您能提示我,请提前致谢。
.ajax() to do the same thing, but not successful. I wonder if it is possible to pass the data obtained from the .aspx.cs to the javascript in the .aspx. Thanks in advance if you can hint me.


您可以尝试以下逻辑。



使用 jQuery 从aspx页面调用 WebMethod 并在中编写上面提到的代码> WebMethod 并将所需值返回到 aspx 调用者 JavaScript 函数。
You can try the following logic.

Call a WebMethod from aspx page using jQuery and write the code you have mentioned above inside that WebMethod and return the required value to the aspx caller JavaScript function.


这篇关于从ASPX.cs到JavaScript的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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