我有这个代码.
xmlhttp.open("GET","getuser.php?q="+str,true);
where q="+str
Run Code Online (Sandbox Code Playgroud)
我想传递第二个var我该怎么做?
我的代码 -
document.getElementById("lblmsg").innerHTML=xmlhttp.responseText;
if(xmlhttp.responseText == 'Available')
{
document.getElementById("newid").value = "";
}
Run Code Online (Sandbox Code Playgroud)
虽然响应文本Available但仍然没有进入条件???
我知道由于JavaScript安全沙箱,无法从JavaScript代码所在的域外部加载xml数据.
但是,如果我使用localhost:8080并且xml文档来自同一台机器中的localhost但是来自8081之类的其他端口,这是否被认为是同一个域?
谢谢
andy e和ken和jacob,谢谢大家:-)
我想在一个URL上发送HTTP PUT请求,以通过使用API更新XML的内容.
URL如下所示:https://domainname.com/someurls/id.xml
我想更新该内容.
但是,当我发送此PUT请求时,我已经看到在Flex 4的网络监视器中,它在此Web上作为POST请求,而我在HTTPService变量中将方法设置为PUT.
所以我收到了错误.那么有没有办法在网上发送PUT请求?或者是否有任何特殊的标题来设置PUT方法?我试过方法标题,但它不工作....
请帮我.....
我去了谷歌,打开了我的萤火虫.我开始键入"in",然后检查Firebug的"NET"选项卡,并发送了几个新的GET请求以获取搜索自动完成建议列表.
喜欢:
GET http://clients1.google.com/complete/search?hl=en&client=hp&expIds=17259,17315,23628,24549,26637,26761,26849,26869,27386,27404&q=i&cp=1
Run Code Online (Sandbox Code Playgroud)
但它们被归类为"JS"部分,而不是"XHR" - 为什么会这样?不是谷歌在幕后制作AJAX GET请求吗?
在页面上SomePage.aspx,通过JavaScript代码(XMLHttpRequest),我调用了SecuredPage.aspx下一个代码:
var httpRequest = GetXmlHttp();
var url = "https://myhost.com/SecuredPage.aspx";
var params = "param1=" + document.getElementById('param1').value +
"¶m2=" + document.getElementById('param2').value;
httpRequest.open("POST", url, true);
httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
httpRequest.onreadystatechange = function() {
//Call a function when the state changes.
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
alert(httpRequest.responseText);
}
}
httpRequest.send(params); // HERE ACCESS IS DENIED.
//---------------------------------------------
function GetXmlHttp() {
var xmlhttp = false;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject)
// Code for Internet …Run Code Online (Sandbox Code Playgroud) 我想写一个简单的Javascript程序,它将获取一个文本文件并使用alert显示它.所以,乐观,我去了W3schools页面,声称提供示例程序,我尝试了一个:
http://www.w3schools.com/dom/tryit.asp?filename=try_dom_xmlhttprequest_first
它不起作用.我替换了他们的URL.我玩他们的代码试图让它工作.依然没有.
我怀疑我的文件是在Comcast上托管的,因为Comcast阻止了对文件的Javascript访问.但我希望我错了.我也尝试过http://yahoo.com,但仍然得到了一个零字节的响应.
这是我最新的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div id="myDiv" > xyz </div>
<script type="text/javascript">
<!--
var xmlHttp = null;
function writeDiv (divName, content)
{
document.getElementById(divName).innerHTML = content;
}
function Fetch()
{
var Url = "http://yahoo.com";
document.getElementById("myDiv").innerHTML = "processing...";
xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = ProcessRequest;
xmlHttp.open("GET", Url, true );
xmlHttp.send(null );
}
function ProcessRequest()
{
if (xmlHttp.readyState == 4) {
writeDiv ("myDiv", xmlHttp.responseText);
}
}
Fetch();
//--> …Run Code Online (Sandbox Code Playgroud) 如何在pywebkit中为file://协议启用xmlhttprequest?
就像铬一样
http://www.google.com/support/forum/p/Chrome/thread?tid=171316324d16747b&hl=en
我有Web应用程序(在Java中),在这里我需要通过jquery或简单的javaScript ajax调用在任何浏览器(包括IE限制XDomainRequest对象)中通过Ajax调用来限制跨域请求。
我的最终目的是在通过某些浏览器设置或设置响应标头进行调用时限制它,以使它不会在第一点本身上进行调用。
如果解决方案是同等政策,请务必说明如何解决。
感谢和问候,Oceanvijai
我运行发送一个JavaScript函数xmlHttpRequest到.ashx(让我们命名它send_req()是对第一次页面加载运行).因为onreadystatechange,我有一个接收XML数据并在页面上显示它的函数(让我们将其命名为getanswer()).
我想每20秒自动更新页面上的XML数据.为此,我setTimeout(send_req(),20000)在最后使用writexml(),但它不更新页面上的数据.我添加alert()的****代码行.它每隔一秒显示在页面上!
如果我没有使用它,我的代码工作正常setTimeout.
这是我的代码
var Population = "";
var Available_money = "";
var resource_timer;
var httpReq_resource;
function send_req() {
if (window.ActiveXObject) {
httpReq_resource = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
httpReq_resource = new XMLHttpRequest();
}
var sendStr = "user_id=1";
if (httpReq_resource)
{
httpReq_resource.onreadystatechange = getanswer;
httpReq_resource.open("POST", "Answer_Resource_change.ashx");
httpReq_resource.send(sendStr);
}
}
function getanswer() {
var results = httpReq_resource.responseXML;
if (httpReq_resource.readyState …Run Code Online (Sandbox Code Playgroud) xmlhttprequest ×10
javascript ×7
ajax ×4
apache-flex ×1
browser ×1
cross-domain ×1
file-uri ×1
firebug ×1
flex4 ×1
get ×1
gtk ×1
httpresponse ×1
https ×1
python ×1
variables ×1
webkit ×1