問題描述
我正在使用這個 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 獲取價值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!