How to create a web widget for websites?

Good afternoon. I developed a project for fast communication with customers, similar to the American service, but reworked under the Russian realities. The fact that now the user creates their own page in the service and places a link to your website page in the, etc. But now there is a demand for creating a multi-user web widget that people can embed on your website. The question is, what is better to use tools for such tasks? You need that people can insert the widget code on the website, and therefore displayed his personal content from the page in my service. For example how I have done it jivosite, vk, facebook, etc.

At the moment the whole service I built in PHP together with a MySQL database. I would like to understand the principle of operation of the widgets and that their development is worth exploring.
June 10th 19 at 15:39
3 answers
June 10th 19 at 15:41
As mentioned above, Yes, you can and ifram, but it has a drawback. It can broken not on all clients.
On account of the script, I think this is the best option, though complicated.
We once implemented a widget, only a little different. I will describe how we did.
The user had to place a div where you had to load our widget. And connected a single js file that is responsible for everything. That is, he added your styles, checked on jquery and if no, then connect,
So he connected me.card.
In that div, which is placed initially, was gradually filled with the desired form.
And the overall picture was generated of the whole widget.
Also provided versionist widget that would have the users who have already put the widget did not should communicate after updating the code.
Yes, quite not easy, but they did work.
iframe is not the best solution because the user page in full screen and in the case of such embedding - will look not very correct. The fact that I'm with JS principle not compatible yet (working as reported earlier, only php). I am interested in the question - as with JS I can turn third-party site in its database? Or how does this process happen?

There is an assumption that the widgets work like this:
1. Built-in js refers to the js on my server and renders everything on the site user.
2. js on my server drawn somehow to the database and returns the data.
3. This data is transmitted to js which the user embeds in the website.
Do I understand correctly? So this should work? Or some sort of other structure should be? - brennon.Armstrong20 commented on June 10th 19 at 15:44
js, on the user side does what I described in the first example. That is, renders all the necessary. Just write a comment, you can simplify your work, immediately make ready a div block with all styles, though not very good it will look. But that's just a fallback.

Next, I would do the data exchange using mini api, i.e. the user gives up their token(for example) to your server. Js sends get/post request to your server. Only treatment must go on *.php, js to do as you wrote is not very practical, so it is better to access the php files. This php file will query from the user, process it and give it to the js format.
The widget on the client side will process the js and put down all the variables in its place.
This is the easiest option that I can offer on the fly. Although it can depend on the specific task.

Depending on what your task is and what the requirements are, and I completely don't know. My version might not fit. We need to understand.

I on your place took a few widgets that did serious company and would study how they work. - Kamron29 commented on June 10th 19 at 15:47
June 10th 19 at 15:43
Ifram, which displays the appropriate page with your service.

You can, of course, you're tripping, and draw JS-om the whole interface on the fly via a download from your server script, but it is quite a chore. Therefore, ifram.
June 10th 19 at 15:45
I don't know. Like the developer and have already developed a project and just open the website where the widget and see what it's made of, suddenly became a challenge?

Widget is nothing but the normal html, css, js and any backend.

Find more questions by tags jQueryPHPJavaScriptMySQL