English 中文(简体)
• 要求使用URL并取得回报价值。 Jquery和Javascript 均显示收益价值[复制]
原标题:Call a URL and get the return value. both Jquery and Javascript doesnt display the return value [duplicate]
This question already has answers here:
Closed 12 years ago.

Possible Duplicate:
XMLHttpRequest.responseText doesnt write the value when calling a URL

I ve written the code in both javascript and jquery to call a URL and get the return value by referring here and here.

但是,牛页的回报值在我的html档案中显示。 自2006年以来 我要问一下,我是否需要把呼吁作为交叉张贴? 如果是的话,你能否解释我?

www.un.org/Depts/DGACM/index_spanish.htm Java印代码为。

 <script type="text/javascript" >    
 var req ;
 // Browser compatibility check          
 if (window.XMLHttpRequest) {
 req = new XMLHttpRequest();
 } else if (window.ActiveXObject) {

 try {
 req = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {

 try {
 req = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (e) {}
 }

}


var req = new XMLHttpRequest();
req.open("GET", "http://www.example.com/Default.aspx?usrname=john",true);
req.onreadystatechange = function () {
document.getElementById( divTxt ).innerHTML = "My Status: " + req.responseText;
}

req.send(null);
</script>

</script>
<html>
<head/>
<body>
<div id="divTxt"></div></body>
</html>

The output I get is : My Status :

The JQuery code is

 var html = $.ajax({
 url: "http://www.example.com/Default.aspx?usrname=john",
 async: true
 }).responseText;
 document.getElementById( divTxt ).innerHTML = "My Status: " + html;

The output I get is blank page

PS:我是。 由于我的问题没有得到适当回答,这个问题再次出现。

** 本文件迟交。 本文件迟交。

> EDIT: in my original code, there is

http://

** 本文件迟交。 本文件迟交。

最佳回答

除非已执行CORS

If you need to get data from somewhere which is not same origin you need to use JSONP

另外,为了解答,试图从地点街上打电话,看你是否收到你要求的有效数据。

问题回答

you are doing several things incorrectly.

First, you re overwriting your req variable (which you initialize for different browsers up on top). So, remove this line: var req = new XMLHttpRequest();

接下来,你再说一.,其范围与你所赢得的美加澳新人民军安全之道不同。 另外,由于你不再允许你离开自己的领域,你又重新开始列入http://,但这只是一点。 最后,你呼吁重新改革国家,但未能注意到将进入几个阶段的现成国家。 你重新寻找第4阶段,实际上做些什么。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签