|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
So I don't really know much about AJAX (I have some books coming in the mail), but as far as I can tell, Javascript would make a call to a PHP page, which would send data back to the Javascript, which would update the existing HTML (using innerHTML or the DOM). In any case, I'm wondering if there is a way to make requests to (PHP) pages outside of a given domain. Here is an example:
I have a plugin for people's websites. What I want to do, is provide them with HTML/Javascript code they can drop on their page. This code will provide a button/link, that when clicked, will "refresh" that portion of the page. However, since I want this "plugin" to be as universal as possible, I don't want to involve any server side scripting languages (like PHP), on the client end. So is it possible for a client's page to use purely Javascript to contact a PHP page (and pass in parameters) on MY site, which would then return some information. That possible? Just off the top of my head, I remembered that I have used a PHP Image generating file that I can link to. All I do is put the filename in the "src" tag like so: <img src="my_php_image_generator.php?text=John"> The code above (if it was pointing at my actual page) would display an image in the page, with the text "John". Could I do something like that, but with text instead? Also, could that be AJAX enabled as well? Hope I'm heading in the right direction... Thanks in advance, you guys have been very helpful so far! |
|
#2
|
|||
|
|||
|
Yes, that is something to the effect of what AJAX actually does...when you reference a PHP page outside of domain, I believe you just specify the url address fully. What I would do to update your text on the page, simplistically speaking, is to assign a variable to the text on the page. Then, just have the AJAX call update the variable. Your workflow would look something like this:
(this is untested, but you get the idea) Code:
var infoHttp = new XMLHttpRequest();
//(or, it would be new ActiveXObject() for non Firefox/etc...
infoHttp.onreadystatechange=function(){
if(infoHttp.readyState==4){
//write it to your javascript variable here
}
}
infoHttp.open("GET","http://path.com/to/script.php",true);
infoHttp.send(null);
__________________
Errors have been made. Others will be blamed. Group Member, Dallas PHP Users Group <b>(DPUG)</b> --... ...--, Eric |
|
#3
|
|||
|
|||
|
Great! Thanks for the info! You know a good site for learning AJAX?
|
|
#4
|
|||
|
|||
|
AJAX is really simple, contrary to popular belief. If you've got some javascript knowhow, and a little xml, you can pick up AJAX in no time. I learned a while ago, but I don't remember where from. There is a tutorial on codewalkers for it though:
http://www.codewalkers.com/c/a/Miscellaneous/Quick-and-Dirty-AJAX-Tutorial/ |
|
#5
|
|||
|
|||
|
Quote:
Thanks again! Also I just got my book in the mail! I got "AJAX and PHP" by Packt Publishing (Cristian Darie, Bogdan Brinzarea, Filip Chereches-Tosa, Mihai Mucica). I flipped through it a little and it looks pretty good. |
|
#6
|
|||
|
|||
|
are there some more (good) tutorials ?
__________________
EAT THIS PIECAKE!!! liked the old site more |
|
#7
|
|||
|
|||
|
In this book? Or are you asking the others? This book seems to have a good deal of sample code, for different applications, but I don't know exactly what the samples do. Liek I said, I just got it :-/
|
|
#8
|
|||
|
|||
|
Tutorials.....Google is your friend :-)
|
|
#9
|
||||
|
||||
|
I learned everything I needed to make my first AJAX app from Rasmus's 30 second ajax tutorial. Just google that and you're golden. I have since refined my skills and technique but this will give you all you really really need.
__________________
There is no spoon. |
|
#10
|
|||
|
|||
|
I'm all set on knowledge now, but I think I'll check it out anyway to compare the techniques to the book I have!
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Programming Theory > AJAX sepcific question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|