Embed PHP code as Widget?

Typr451's Avatar
Go4Expert Member
I've got a little problem, I've got this application that produces a PHP-site and I'm trying to figure out how it can be embedded as a Widget on another site. My fingers are raw from Googling and my eyes hurt from from reading pointless articles related to Widgets that say nothing about how to load a normal HTML and PHP site as a Widget. The closest thing I got was someone writing HTML-code in a string and printing it in JavaScript, I wanted to do the same but I can't find a function to load the content of a URL into a string, plus from lurking i forums a lot say that's impossible.

It've gone so far that I think I've completely misunderstood what a Widget is, isn't it just an external site, anywhere, which you load in another site? Why isn't anyone using iframes? I tried those but my host wouldn't allow it, so I've been checking some Widget-embedd examples and they use JavaScript for some reason.

Anyway, I won't bore you with details, it should be so simple. If it wasn't clear: I've got a couple of pages, JavaScript, XML and PHP that fill up a DIV with some application. I want to be able to load that application as a Widget somewhere. Thanks
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Yes best part is JavaScript and I have done it for my blog as well.

http://www.codeitwell.com/recent-posts.js

See this and you can embed this js file on any of your site and it will start showing the recent posts from my blog.

You have the have the ability in your PHP server to create a file which can make such an output and then its just plain adding in any page is fine.
0
Typr451's Avatar
Go4Expert Member
I'm not sure I understand. What I got looks a lot like the AJAX-example on W3Schools with a XML-file as the database, a JavaScript-file that prints the information from a PHP-file and just the plain HTML-file that loads the JavaScript.

What I first tried was using an iframe on my blogg that linked to the PHP-page (which has all the data I want) but it wouldn't allow it, just like my host. Then, since I could print HTML directly with JavaScript on the blogg, I tried printing some PHP-code but it didn't work. After that I tried loading the XML-file directly in JavaScript (too the file on my server with full URL) but that didn't work as well.

What I think I need is somehow load the content of a URL (my PHP-page) into JavaScript as plain HTML and just write it.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
if iframe does not work I think you can change your host.

If you are looking for inclusion of a phpfile you can make a second file on the server which converts your html into a javascript