Programming Theory
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesProgramming Theory

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old May 1st, 2007, 01:13 PM
jbubrisk jbubrisk is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 30 jbubrisk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 25 sec
Reputation Power: 3
Question AJAX sepcific question

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!

Reply With Quote
  #2  
Old May 1st, 2007, 02:39 PM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 7 m 51 sec
Reputation Power: 5
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 &lt;b&gt;(DPUG)&lt;/b&gt;
--... ...--, Eric

Reply With Quote
  #3  
Old May 2nd, 2007, 11:08 AM
jbubrisk jbubrisk is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 30 jbubrisk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 25 sec
Reputation Power: 3
Lightbulb

Great! Thanks for the info! You know a good site for learning AJAX?

Reply With Quote
  #4  
Old May 2nd, 2007, 10:34 PM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 7 m 51 sec
Reputation Power: 5
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/

Reply With Quote
  #5  
Old May 3rd, 2007, 12:19 PM
jbubrisk jbubrisk is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 30 jbubrisk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 25 sec
Reputation Power: 3
Quote:
Originally Posted by nawlej
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/


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.

Reply With Quote
  #6  
Old May 3rd, 2007, 02:29 PM
roelor roelor is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 81 roelor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 25 m 6 sec
Reputation Power: 3
are there some more (good) tutorials ?
__________________
EAT THIS PIECAKE!!!
liked the old site more

Reply With Quote
  #7  
Old May 3rd, 2007, 04:13 PM
jbubrisk jbubrisk is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 30 jbubrisk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 25 sec
Reputation Power: 3
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 :-/

Reply With Quote
  #8  
Old May 3rd, 2007, 08:22 PM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 7 m 51 sec
Reputation Power: 5
Tutorials.....Google is your friend :-)

Reply With Quote
  #9  
Old November 4th, 2007, 04:09 PM
icandothat's Avatar
icandothat icandothat is offline
Super Moderator
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,657 icandothat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 22 h 10 m 4 sec
Reputation Power: 4
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.

Reply With Quote
  #10  
Old November 6th, 2007, 09:59 AM
jbubrisk jbubrisk is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 30 jbubrisk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 25 sec
Reputation Power: 3
Wink Thanks!

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!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesProgramming Theory > AJAX sepcific question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek