Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
load IW Form on website
#1
Question 
Hello,

I'm running into an issue about using IntraWeb on a website.
I've made a IntraWeb project that works fine as a standalone application. However, I need the html result of this project, to be load into another webpage that doesn't use IntraWeb.

What I'm using is ajax. By clicking on a button, an ajax request is send and asks the standalone application to return the html content, and add it to a specific div of the non-IntraWeb page. After the ajax request, I get all  my code in the result variable, and that is fine. But somehow, I don't know why, the inclusion of the javascript files of the IntraWeb project, is trying to be loaded from the IP of the non-IntraWeb project rather than the standalone application.


More specifically :
1. I'm on http://192.168.1.149/accueil

2. I clicked on a button which executes the code below
Code:
        $('#load_iw_button').click(function () {

        console.log('clic sur IntraWeb');
        var une_url = "http://192.168.1.134:8888";
        $.ajax({
        type: 'POST',
        url: une_url,
        xhrFields: {
            withCredentials: true
        },
        success: function (response) {
            //console.log('action_delete() reponse: ' + response);
           
            console.log(response);
           
            if (response !== '') {
                console.log("ajout dans la div");
                $("#div_iw").append(response);
            }
        }
    })
            .done(function (data) {
                //console.log('done');
            })
            .fail(function (request, error) {
                console.log('action_delete(): fail');
                console.log(request);
                console.log(error);
            });

3. I get the IntraWeb code as the console.log(response) send me this :
Code:
<!DOCTYPE html>
<html lang="fr">
    <head>
<meta charset="utf-8">
<meta name="generator" content="IntraWeb v15.1.15 Serial 202037997">



<link href="/$/css/IWNotify__2753029400.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" nonce="zjrQMCyHs4VMZVlOn8g76KA5aQ8">
var GURLBase="/$/", GAppID="nSkvmshq0xMbxMTaN6nhYvgAzZq", GTrackID=1;
function doOnReady(f){
   var d = document;
   if (d.readyState!="loading") f();
   else if (d.addEventListener) d.addEventListener("DOMContentLoaded", f);
   else d.attachEvent("onreadystatechange", function(){if (d.readyState=="complete") f();})
}
</script>
<script type="text/javascript" src="/$/js/IWLib__2067137548.js"></script>
<script type="text/javascript" src="/$/js/IWBase__2847485697.js"></script>
<script type="text/javascript" src="/$/js/IWGecko__1086946337.js"></script>
<script type="text/javascript" nonce="zjrQMCyHs4VMZVlOn8g76KA5aQ8">
function rollon_GRD1(row, where){
  var rowElement = IW.$(row);
  if (rowElement && rowElement.style){
    if (where == "over"){
        currentcolor = rowElement.style.backgroundColor;
        rowElement.style.backgroundColor = "";
    } else {
        rowElement.style.backgroundColor = currentcolor;
    }
  }
}
function CHECKBOXTOUS_onchange(event) {
checkBoxAllChange();
return true;
}
function Body_OnBlur(){GSubmitting = false;}
function FormDefaultSubmit(event){return false;}
function IWTop(){return window;}

function checkBoxAllChange(){
if ($('#CHECKBOXTOUS_CHECKBOX').prop('checked')){
    $('#TBLGRD1 tr').each(function(){
        $(this).find('td:first span input').prop('checked', true);
    });
} else {
    $('#TBLGRD1 tr').each(function(){
        $(this).find('td:first span input').prop('checked', false);   });
}}
// and so on ...


4. But it also displays multiple errors like that :
Code:
VM3897 jquery-3.3.1.min.js:2 GET http://192.168.1.149/buroclic_online/js/bootstrap_table/tableExport.jquery.plugin-master/libs/jsPDF/jspdf.min.js 404 (Not Found)

The issue here, is that it's trying to get JS files from 192.168.1.149, but JS files are stored on 192.168.1.134, since that's the url I put on the ajax request


I'm pretty new about IntraWeb, maybe I miss understood something, let me know !

Thank you for you time and your answers
Reply
#2
Hi, look this demo: https://github.com/Atozed/IntraWeb/tree/...ntHandlers and create your ContentHandle to respond to your non iw app. You can create something like this:
Code:
http://192.168.1.134:8888/GiveMeSomeHTML
Look in ServerController.
Code:
with THandlers.Add('', 'GiveMeSomeHTML', TContentHTML.Create) do begin
  CanStartSession := True;
  RequiresSessionStart := False;
end;
In your content:
Code:
if Assigned(aReply) then begin
  aReply.ContentType := MIME_HTML;
  aReply.WriteString('<html><head>etc</head></html>');
end;
Reply
#3
Thank you for your response,

Indeed, I followed all the steps from the demo, and 192.168.1.134:8888/GiveMeSomeHTML gives me the string that was written on the handler.
However, I want this URL to return me all the HTML generated from the Delphi form so I can add buttons in IDE, and then, call this URL via ajax to implement it into a div of my main page (on 192.168.1.149/accueil), but currently, I am returning a string.

How can I use the Handler, but instead of writing strings, I could write an entire form, or turn the form to the matching HTML, convert it to string, and pass the string to the WriteString method ?

Again, thank you for your time Shy
Reply
#4
(03-12-2020, 04:29 PM)Naxe67 Wrote: Thank you for your response,

Indeed, I followed all the steps from the demo, and 192.168.1.134:8888/GiveMeSomeHTML gives me the string that was written on the handler.
However, I want this URL to return me all the HTML generated from the Delphi form so I can add buttons in IDE, and then, call this URL via ajax to implement it into a div of my main page (on 192.168.1.149/accueil), but currently, I am returning a string.

How can I use the Handler, but instead of writing strings, I could write an entire form, or turn the form to the matching HTML, convert it to string, and pass the string to the WriteString method ?

Again, thank you for your time Shy
Thought you may be looking for what Jose suggested but maybe we're confused about what you're trying to do.

Are you saying that you want the other server to "pass through" the Intraweb form?  Capture the form content?  Something else?

Dan
Reply
#5
No problem, I may not have made it clear enough.

Here's what I want to do with some pictures :


This is the form made by IntraWeb, and that's what the standalone application is giving me at 192.168.1.134:8888 when i type it into Chrome :

[Image: P3FfKNY.png]

And I want this result (as HTML), to be returned when I am calling ajax and to put it in the other page, exactly like it is in this screenshot for "A reply" (after click on button) :
[Image: gFOHeZ2.png]

Making an ajax call to 192.168.1.134:8888 is giving the HTML like I want, but it tries to load JS files from the wrong server and I don't know why.

i.e. : 
I am on 192.168.1.149 website. I click on the button, it makes an ajax call to 192.168.1.134:8888. It gives me the HTML (i saw that thanks to console.log), but it doesn't load JS files.

Here's a sample of the errors :
Code:
GET http://192.168.1.149/buroclic_online/js/bootstrap_table/tableExport.jquery.plugin-master/libs/jsPDF/jspdf.min.js 404 (Not Found)
GET http://192.168.1.149/$/js/IWBase__2847485697.js 404 (Not Found)

When making the ajax call, it returns me the HTML, but all JS files are trying to be loaded from 192.168.1.149, and should be loaded from 192.168.1.134 since the ajax call is made to 192.168.1.134.

Finally, here's how i include JS file from the ExtraHeader property of my form :
Code:
        <script src="./js/bootstrap_table/tableExport.jquery.plugin-master/libs/jsPDF/jspdf.min.js" type="text/javascript"></script>
I already tried to replace src with /js/... and with /$/js/... but there was no improvement.

Anyway, thank you for your response !
Reply
#6
Hi, now i understand are you trying to do. Try Frame in your other page. Something like this:
Code:
<frameset cols="25%,50%,25%">
  <frame src="http://192.168.1.134:8888/$/start">
</frameset>
Reply
#7
Hi,

Thank you for this tip, indeed, it works. However, it seems like it doesn't match well with responsive. I also tried iframe but it gives me something like this :
[Image: n3xTSqt.png]

I know how to get rid of scrollbars but the problem is that I cannot set the width of the first iframe to fit-content, and the other iframe taking all available space. I tried a lot of things and nothing worked. Moreover, it seems that html, body, and the div of the menu got a width of 30px but the "document" of the iframe takes what it display in the screenshot (like 300px).

Do you have any clue please ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)