Get value from AJAX using Javascript and ASP(使用 Javascript 和 ASP 从 AJAX 获取价值)
问题描述
我正在使用这个 Ajax 代码.但我不知道如何使用 Javascript 在服务器端 asp 上检索 value1 的值.
I am using this Ajax code. But I dont know how i will retrieve my value of value1 on my server-side asp using Javascript.
在我的服务器端,我想要类似的东西<%var newdata = value1 (这是来自服务器端的 - 在此处发送)%>
On my serverside I want to have something like <% var newdata = value1 ( which is the one from the serverside - which was send here) %>
请帮忙!!!谢谢一百万
Please Help !!! thanks a million
我知道 PHP 可以,但我如何使用 javascript
I know it is possible with PHP but how do i do with javascript
<script>
function ajaxNow(_data)
{
var xmlHttp;
try
{
/* Firefox, Opera 8.0+, Safari */
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
/* newer IE */
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
/* older IE */
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser is old and does not have AJAX support!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
/* this puts the value into an alert */
alert("Value read is: "+xmlHttp.responseText);
}
}
xmlHttp.open("GET","ajax_file.asp?value1="+_data,true);
xmlHttp.send(null);
}
</script>
推荐答案
当您的 Ajax-Request 成功时,您将在 Request-Object 的 QueryString-Collection 中拥有 querystring-variables.
When your Ajax-Request succeeds you will have the querystring-variables in the QueryString-Collection of the Request-Object.
在服务器端可以这样工作:
Could work like this on the server side:
<% var newdata = Request.QueryString("value1"); %>
这篇关于使用 Javascript 和 ASP 从 AJAX 获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Javascript 和 ASP 从 AJAX 获取价值


基础教程推荐
- 如何在特定日期之前获取消息? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01