Link to home
Start Free TrialLog in
Avatar of Scott Fell
Scott FellFlag for United States of America

asked on

XMLHTTP not working in safari 5.1

This vbscript code does not work in safari 5.1.  It works fine in safari 6 and other browsers.

The page is at mysite.com/folder1/thispage.asp and is calling mysite.com/folder2/folder3/

I have a php on another domain and server calling the same thing by sending  a post and works fine as well.

Safari 5.1 just stops working at this point in the code.  In some cases, it downloads the asp page (just the rendered html).  When I take this out, all good.  I have tried loading this above all html and inside of html.  Same result.

      dim myData
		DataToSend = "d1=abc&d2=xyz"
		dim xmlhttp 
		set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
		xmlhttp.Open "POST","https://mysite.com/folder2/folder3/",false
		xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
		xmlhttp.send DataToSend
		Response.ContentType = "text"
		myData= xmlhttp.responseText
                Set xmlhttp = nothing

Open in new window

Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

That doesn't make any sense.  That code runs on the server, not in Safari.  Any chance that the code that is being received is another complete page with <head> and <body> sections inside the <head> and <body> sections  of the main page?  Look at the 'View Source' and see if you're getting a properly formatted page when it works.
Avatar of Scott Fell

ASKER

Yes, I was planning on checking that out today.   However, I created a wordpress plugin/function using the php version and it hits the same exact page from an outside domain and that works fine.  

Originally, I thought it might be a log in issue because of the way safari handles sessions and redirects.  But as I put breaks in my code, this is what I was able to isolate.  I just found a mac with safari 5 I can test more on today.  

I did try removing the response.write portion completely and moving the httppost above the html and  inside the html.  Even without writing the data it fails.  The incoming data is just a series of div's and tables without much white space.  I threw it in the validator and all good.  I even check the validation on the WP site and and found some old sql injection(not pertaining to what I did of course) but it still works.
I'm pretty sure that PHP and ASP will not generate 'exactly' the same code.  So the PHP version works and the ASP doesn't?
The odd thing is it is only safari 5.1.  My client let me know and I confirmed it by finding a mac with 5.1.  It must be  the way xmlhttpost works on that browser.    I do want to test on some very plan content just to eliminate.  But the content it is loading is simply a series of h2 tags and tables and all validated.  I know there are multiple ways to send a  post and I may just use jquery ajax instead of classic asp.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yea, I will let you know when I test it out where the page it posts to will be just one word and nothing else.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cool, thanks for the points.