I'm writing a script to send posts to a web forum. I find that
MSXML2.XMLHTTP object could communicate with web server but I can't make
it send cookie which is needed for post authentication. I have searched
google and read some articles including: Code:
I'm trying to do use XMLHTTP to do a POST in the following JavaScript snippet.
var xml = new ActiveXObject('Microsoft.XMLHTTP'); xml.open("POST", "http://some/url/", false); xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xml.send("username=myusername&password=mypassword"); document.write(xml.responseText);
This works fine in Internet Explorer 6 SP2. However, I would like to use https, rather than http. When I change the URL to https and reload the page, I get an error: "The download of the specified resource has failed". As a test, I tried running the same code in Firefox (changing the first line to "var xml = new XMLHttpRequest()"), and this worked for both http and https perfectly, although using https causes a dialog box to pop up asking the user to accept the SSL certificate. Unfortunately, I really need this to work in IE.
I found a couple of discussions on Usenet about this, but none that seemed to give me a clear answer to this issue. Does anybody know what might be wrong or how I might fix it?
Just playing around with xmlhttp at the moment. I was just wondering if there is any reason (browser compatibility etc) the response data has to be formatted in xml, or can I send csv or whatever else if the handler is up for it?
I've been looking into the possibility of using XMLHTTP for my enterprise application but I still have a question.
When you send the request to the server, how does the server know how to handle the request? (i.e. how do I specify what method to call in my java servlet?)
I'd appreciate any help on this.....I've only got a vaey basic knowledge of javascript and I am fluent in java.
Using XMLHTTP and DOM I'm able to load new HTML page content.
I'd now like to load small snippets of javascript with the HTML markup and have that <script> incorporated into the page. If any of the loaded script exists outside a function definition (eg: a call to a function), I'd like that code to be executed as soon as its added to the DOM.
Can anyone suggest the best way to do this? I've Googled but not found anything comprehensive. Do I need to use the eval() method or is there a better way?
There is a problem with XMLHttpRequest and Firefox when the function that makes the asynchrounous request is called from another window. The URL of the window does not change to the next page in which i am displaying the response.
I've picked up a copy of "Foundations of Ajax" and was working through one of the initial examples and ran into a problem. xmlhttp.status always returns 0. I can run the following code and get the expected text returned from the server but only if I comment out the conditional that checks xmlhttp.status
<script type="text/javascript"> var xmlHttp; function createXMLHttpRequest() { if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); alert('ActiveX xmlhttp object instantiated'); }
else if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); alert('Non-IE xmlhttp object instantiated'); } }
I don't understand how xmlhttp.responsetext can return the text in the file if xmlhttp.status returns 0. I'm running apache 2.055 on my local xp box. apache is a stock cfg except for vanilla changes I made to add php5.
i want to postload javscript from another javascript. This works fine in firefox and IE6 for macIE i can use an Iframe to load the code and inject it with insertAdjacentHTML The problems arise with safari and opera. Both load the new code with XMLHttpRequest, but the code is no 'executable'
To make this possible on IE i had to use the magic 'DEFER' attribute. (Sync or Async ist not the issue)
I'm trying to translate an asp application, i have some difficulties with a particular line : --- Set myxml = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0") ---
Classical ajax exemples rather use : [...] req = new ActiveXObject("Microsoft.XMLHTTP");
.... But i'm not sure the ActiveXObject is identical to the original : Set myxml = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
I'm not an asp expert, can you give me some tips on that question ?
I am trying to use AJAX and JSON to do this. I have copied an example of using HttpRequest Object as the backbone of this from http://www.w3schools.com/dom/dom_http.asp. Further, I am enclosing both of my files here, in full as opposed to mere snippets. This code does what I wish it to do except:
1. It does not update when getdata.php is rewritten. On non MSIE broswers, it shows when first invoked, but not subsequently. 2. It fails altogether under MSIE (6.026 SP1 || SP2) -- I never get xmlhttp.readyState==4 under MSIE.
I create an ActiveXObject("Msxml2.XMLHTTP") from my HTML page to submit (i.e. post) XML to a server. I can see the content of the XML response via javascript alert(xmlhttp.responseText). Is there a way to display the content of xmlhttp.responseText on a new page?
I tried document.write(xmlhttp.responseText) but this does not display the XML structure....
Say x in a XML Http Request Object ... meaning it's either XMLHttpRequest (firefox) or ActiveXObject (IE)
This line of code works in firefox... x.someProp = "someValue"; alert(x.someProp);
But in IE I get "Object doesn't support this property or method" I need to place a custom property on the object. Is there any way I can do that in IE?
Save the following code as "WHOIS.hta". Then launch it(For Windows 9x+ & IE 5.5+). And it's easy to convert it to asp. So it may works well on your web server, too.
function getReady(){ if(xmlhttp.readyState==4){ result.value=xmlhttp.responseXML.selectSingleNode('//GetWhoISResult').text.replace(/[sS]+Network Solutions reserves the right to modify these terms at any time./,'') submit.disabled=false submit.innerText='Submit' } } </script> </body> </html>
how to Get xmlHttp.responseText when you call from IFrame? I get empty xmlHttp.responseText, while when calling server from out the IFrame, I get the responseText without problem, how can I solve this problem?
I'm working on a script that calls my php file, checks the db and returns text. If the returned text="bad" then i want the var "bad" to be set to 1. at the bottom of my script, if anything has tripped bad=1 then it returns false and the form doesn't submit...everything works great except for this one piece so i was wondering if you guys might offer me some insight
I need to turn xmlhttp.responseText into a column of links that will be displayed in a popup div.I've defined xmlhttp.responseText as var named txt with: var txt=xmlhttp.responseText;
That produces a var with comma delimited values. I'd like to proceed by passing txt through a For Loop that will create the links, but I can't find a method that will count commas.
How do I return the number of commas in javascript?
I have a javascript that is supposed to read a text file (a log from a php script) and it should be shown in a html page. Even more, it should read that txt file again every 10 seconds and update the result every time on the page.
I use xmlhttp for this, after a suggestion from someone on this forum. My script is working well, but only the first time the page is loaded. From then on it becomes unrelieable and I dont know why.
This is the first part: loading a function in the body tag, and a browser version check, I dont think there is any problem in this.
And this works, if I load my page then it shows exactly the content of buffer.txt . And if a bit later some data is added to the txt file, then it doesnt show up in the xmlhttp page , its still the same content as from the beginning so it didnt update. But there is something really weird about it, if I open up a second browser window and typ in the complete url of the buffer.txt file, and visit that page and look at the new data... then within 10 seconds the new part is added to the xmlhttp page. So the javascript function doesnt work, unless I refresh the page it is supposed to read. I've tried to mimic that, with a php script in crontab that would read buffer.txt through file(); or fopen(); every minute , but that didnt seem to work.
I dont think there is anything wrong with all the xmlhttp part of it, but rather with the way I try to integrate it into a loop. But this setup with setTimeout is the only way I know to make a function repeat itself with a few seconds delay after every step.
So, could anyone please point out how this could be solved ? Maybe another way to loop the xmlhttp part perhaps?
I am trying to populate two select boxes with over hundred option elements for each. I have succeded in doing so but with a little problem. I make two xmlhttp calls one after another. What happens is that if the first call doesn't make it before the second, the data in the first select box fails to load and the second box succesfully loads data. I am new to the Ajax world but i am sure i am not doing it right.