Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Widget?

Status
Not open for further replies.

alphacooler

Programmer
Aug 29, 2005
73
US
How does one put together a "Myspace type widget"?

Basically i'd like to generate some javascript that when a user puts it on their blog will pull data off my server via a php script and display it nicely (very similar to those little Flickr boxes you see around the web these days).

I'm 100% clueless as to the broad-strokes on something like this.

Thanks!
 
So you want your code inserted into someones MySpace page to display content from another server?
You can use AJAX to execute and return results from the PHP page on your server and display it, the questions is will the javascript be allowed into the MySpace page or will it get filtered?

In any event it sounds like you will need to use AJAX to do this so begin your research there.



At my age I still learn something new every day, but I forget two others.
 
Thanks for the reply theniteowl,

but there seems to be something missing from that explanation. I know how to use the AJAX framework (at least enough to get by) but how does something actually get outputted on their blog? Yes I can use ajax along with a php script to pull up results on my end, but how do I have the widget call home to the server (providing userID, and other vars) and then SEND output BACK to be displayed on their blog?

Maybe I could just give them an iFrame with a src url holding all their info? So basically they are just displaying the output of my page in their frame?
 
That is what AJAX does. The javascript on the page makes an AJAX call to execute the code on your server and returns the results of that execution to your javascript which can then display the information however you like.

I may be misunderstanding what you are asking but the above sounds like what you want. The assumption is that the person in question is inserting your code into his page and that the MySpace framework is not filtering his page to prevent outside code from executing.


At my age I still learn something new every day, but I forget two others.
 
Yes, but I was under the impression that you CANNOT make AJAX calls from one domain to another. For security reasons I believe.
 
I do not think that is true.
You cannot load a web page from another location into a frame on your own page and access that page content as if it were native to your own. Some people would do this to try and get some functionality from another site onto their own by grabbing the live page and stripping out content they do not want in it. Or people may try to mislead you by presenting you what looks to be a legitimate page for a logon of another site but intercepting the logon info typed in.
An AJAX call though is not about loading an existing page from another site, it is about executing a page on that other site and getting back the results returned from that page. The results come back (as far as I know) just as text and you use that text however you lik in your own page.



At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top