feat: open webhook response (HTML/PDF) in new window, update success text

- Replace fetch() with hidden form POST + target='_blank' so the webhook's
  auto-download HTML page opens in a new tab/window
- Send form-encoded fields (not JSON) since webhook expects POST form data
- Update success message: 'A new window has opened with your personalized
  Odoo project plan. The download will start automatically after research
  is complete.'
- Remove dead bizDownloadBtn references (button no longer needed)
This commit is contained in:
2026-08-20 15:28:25 +00:00
parent 87874d0f34
commit b2d2677a34
2 changed files with 31 additions and 28 deletions
+1 -2
View File
@@ -418,8 +418,7 @@
<div class="biz-success" id="bizSuccess" style="display:none">
<i class="fas fa-check-circle"></i>
<h3>Your project plan is being prepared</h3>
<p>Download your personalized PDF below — a custom Odoo implementation roadmap tailored to your business.</p>
<a class="btn btn-brass btn-lg" id="bizDownloadBtn" style="display:none" download>Download Your Project Plan &darr;</a>
<p>A new window has opened with your personalized Odoo project plan. The download will start automatically after research is complete.</p>
</div>
</div>
</section>
+25 -21
View File
@@ -583,7 +583,6 @@ var si = 0,
var form = document.getElementById('bizForm');
if (!form) return;
var success = document.getElementById('bizSuccess');
var downloadBtn = document.getElementById('bizDownloadBtn');
var submitBtn = document.getElementById('bizSubmitBtn');
form.addEventListener('submit', function (e) {
@@ -600,30 +599,35 @@ var si = 0,
submitBtn.textContent = 'Generating...';
submitBtn.disabled = true;
fetch('https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/report', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
/* Create a hidden form to POST to the webhook and open response in new window */
var f = document.createElement('form');
f.method = 'POST';
f.action = 'https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/report';
f.target = '_blank';
f.style.display = 'none';
var fields = {
description: description,
goals: goals,
challenges: challenges,
has_homepage: hasHomepage,
uses_odoo: usesOdoo,
has_developer: hasDeveloper
})
})
.then(function (r) { return r.json().catch(function () { return {}; }); })
.then(function (data) {
has_homepage: hasHomepage ? 'true' : 'false',
uses_odoo: usesOdoo ? 'true' : 'false',
has_developer: hasDeveloper ? 'true' : 'false'
};
for (var key in fields) {
var inp = document.createElement('input');
inp.type = 'hidden';
inp.name = key;
inp.value = fields[key];
f.appendChild(inp);
}
document.body.appendChild(f);
f.submit();
f.remove();
/* Show success message — download will start automatically */
form.style.display = 'none';
success.style.display = 'block';
if (data.download_url) {
downloadBtn.href = data.download_url;
downloadBtn.style.display = 'inline-block';
}
})
.catch(function () {
submitBtn.textContent = 'Generate My Project Plan \u2192';
submitBtn.disabled = false;
});
});
})();