I am not an expert in the widget field, but the "direction" is the use of an iframe, which is dynamically generated on the page on which the widget will be placed.
This is your JS code will write something like:
<iframe src="http://www.mywebsite.com/services/widget.php" {other attributes here} />
An IFrame is usually contained in markup (html), which takes care of the presentation of the widget on the hosting page. Your javascript file may contain handlers (tied to events on your widget, etc.).
The iframe target could be a .php (or other) script that will output html or anything else from your site. The output can contain information / data from your database (Mysql, as you say), and perform any operations with this data.
This is the iframe approach used in several cases. Make sure that you are familiar with the javascript term window before writing JS code in cases where iframes and frames are involved (usually how to handle cases where the page contains frames, which in turn may contain other frames and etc.)
Hope this helps you get started by providing you with a general idea / approach on this topic.
I'm sure you heard about google ads. The way Google ads are included in a web page is clearly explained on Google ad pages. You just add a script and some code, which in turn creates the following html:
<iframe allowtransparency="true" frameborder="0" height="100" hspace="0" id="google_ads_frame1" marginheight="0" marginwidth="0" name="google_ads_frame" scrolling="no" src="http://googleads.g.doubleclick.net/pagead/ads?client="{PARAMS}" style="left:0;position:absolute;top:0" vspace="0" width="900"></iframe>
The content of this frame is the actual ads (links to the page that you see on the page).
The iframe tag is not the only one generated from javascript by Google ads on the page. Other tags (html) are also created that handle presentation issues.
Andreas
source share