d_barszczak Posted October 12, 2007 Share Posted October 12, 2007 hi all, xmlHttp.open("GET", "http://my.website.co.uk/ajax.php", true); The above script gives me a object error but xmlHttp.open("GET", "ajax.php", true); does not but the script is still not running can any one help me!!! Quote Link to comment Share on other sites More sharing options...
d_barszczak Posted October 12, 2007 Author Share Posted October 12, 2007 Hold on a sec!!! It works when the ajax.php script is on the same domain. Please dont tel me this is a limitation of ajax. Quote Link to comment Share on other sites More sharing options...
d_barszczak Posted October 12, 2007 Author Share Posted October 12, 2007 OK This is a problem Any tips on cross browser ajax scripting?? Quote Link to comment Share on other sites More sharing options...
bobleny Posted October 12, 2007 Share Posted October 12, 2007 Um, I don't see any way you can do that. The server shouldn't allow an external script to run like that. It would be a huge security problem. Think about it, all I would have to do is right a script, and have it connect to your site and I would have all your personal files! Now, on the other hand, it might be possible to pass your login information to the server so it will let you in, but I wouldn't have a clue as to how to do that... I will have to do a search, It should be interesting.... Quote Link to comment Share on other sites More sharing options...
bobleny Posted October 13, 2007 Share Posted October 13, 2007 OK, I was reading an article about cross domain AJAX requests, it was really confusing and drawn out... So, the article might have been trying to say what I am thinking about..... Anyways, this is what you could do. You could use AJAX to call a local PHP script. You could then use this local PHP script to call on a script at another server. You might try using the built in include() function to call it.3 You might have to play around with it, but it should work.... Quote Link to comment Share on other sites More sharing options...
d_barszczak Posted October 17, 2007 Author Share Posted October 17, 2007 Thanks for that, Sounds a little complicated. All i need is one value to get from javascript to php so it can be stored in a database. Is it then possible for javascript to write a cookie at the begnining of the page and have php pick it up at the end? Quote Link to comment Share on other sites More sharing options...
Gafaddict Posted October 20, 2007 Share Posted October 20, 2007 Why can't PHP just write the cookie to begin with? Quote Link to comment Share on other sites More sharing options...
d_barszczak Posted October 30, 2007 Author Share Posted October 30, 2007 I am creating a hitcounter script / traffic monitor and one of the stats i need is the users screen resolution. I can only get this from javascript. I then need javascript to pass the variable to php where i can save the value in a mysql database along with other bits of data it collects. I have tried ajax but the counter can be used on any website and ajax will not work cross domain. Please Please someone help me with this. Quote Link to comment Share on other sites More sharing options...
smart85 Posted November 2, 2007 Share Posted November 2, 2007 I think i know the solution... You can load in your script empty image... I saw somewhere code, and it looks something like that: <script language="JavaScript"> var image_path = '<img src="http://example.com/script.php?res='+screen.width+'x'+screen.height+' "/>'; document.write(image_path); </script> Now in 'script.php' you can get users screen resolution from $_REQUEST array... Quote Link to comment Share on other sites More sharing options...
d_barszczak Posted November 12, 2007 Author Share Posted November 12, 2007 Genius! Genius! Genius! Genius! Genius! Genius! Genius! Genius! Genius! Genius! Genius! Genius! Genius! Genius! What a guy. Just when i was about to give up on php & mysql and take up something easier like heavy weight boxing smart85 has saved the day. Thanks a lot smart85!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.