how to load an HTML file inside a div in the view in zend-framework3?
I'm working on an email marketing tool and need to load an HTML template inside a DIV in the view. I'm using zend-framework3.
I tried to use the .load () function, but it is giving error. Can anybody help me??
I'm using something like this:
$('#carregaTemplate').click(function()
var qtdProdutos = $('#qtdProdutos').val();
$(function()
if( qtdProdutos == 1 )
$('#arquivoHtml').load('templates/sem_produtos.html');
if( qtdProdutos == 2 )
$('#arquivoHtml').load('templates/dois_produtos.html');
if( qtdProdutos == 3 )
$('#arquivoHtml').load('templates/tres_produtos.html');
if( qtdProdutos == 4 )
$('#arquivoHtml').load('templates/quatro_produtos.html');
);
);
jquery
|
show 2 more comments
I'm working on an email marketing tool and need to load an HTML template inside a DIV in the view. I'm using zend-framework3.
I tried to use the .load () function, but it is giving error. Can anybody help me??
I'm using something like this:
$('#carregaTemplate').click(function()
var qtdProdutos = $('#qtdProdutos').val();
$(function()
if( qtdProdutos == 1 )
$('#arquivoHtml').load('templates/sem_produtos.html');
if( qtdProdutos == 2 )
$('#arquivoHtml').load('templates/dois_produtos.html');
if( qtdProdutos == 3 )
$('#arquivoHtml').load('templates/tres_produtos.html');
if( qtdProdutos == 4 )
$('#arquivoHtml').load('templates/quatro_produtos.html');
);
);
jquery
Giving an Error Would you mind terribly, telling us what error it is giving you old chap
– RiggsFolly
Nov 14 '18 at 15:28
I'm using something like this: somthing like that? If you show us pseudo code, you are just going to get pseudo answers
– RiggsFolly
Nov 14 '18 at 15:36
Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR
– RiggsFolly
Nov 14 '18 at 15:36
No need to use$(function()
inside a click event handler. Won't cause errors but is just redundant
– charlietfl
Nov 14 '18 at 15:52
Sorry buddy, I'm new here in the stack and I'm going to rephrase ... I'm using exactly the above function and I get the error 500 @RiggsFolly
– Ernane
Nov 16 '18 at 10:54
|
show 2 more comments
I'm working on an email marketing tool and need to load an HTML template inside a DIV in the view. I'm using zend-framework3.
I tried to use the .load () function, but it is giving error. Can anybody help me??
I'm using something like this:
$('#carregaTemplate').click(function()
var qtdProdutos = $('#qtdProdutos').val();
$(function()
if( qtdProdutos == 1 )
$('#arquivoHtml').load('templates/sem_produtos.html');
if( qtdProdutos == 2 )
$('#arquivoHtml').load('templates/dois_produtos.html');
if( qtdProdutos == 3 )
$('#arquivoHtml').load('templates/tres_produtos.html');
if( qtdProdutos == 4 )
$('#arquivoHtml').load('templates/quatro_produtos.html');
);
);
jquery
I'm working on an email marketing tool and need to load an HTML template inside a DIV in the view. I'm using zend-framework3.
I tried to use the .load () function, but it is giving error. Can anybody help me??
I'm using something like this:
$('#carregaTemplate').click(function()
var qtdProdutos = $('#qtdProdutos').val();
$(function()
if( qtdProdutos == 1 )
$('#arquivoHtml').load('templates/sem_produtos.html');
if( qtdProdutos == 2 )
$('#arquivoHtml').load('templates/dois_produtos.html');
if( qtdProdutos == 3 )
$('#arquivoHtml').load('templates/tres_produtos.html');
if( qtdProdutos == 4 )
$('#arquivoHtml').load('templates/quatro_produtos.html');
);
);
jquery
jquery
edited Nov 14 '18 at 15:24
RiggsFolly
70.9k1864111
70.9k1864111
asked Nov 14 '18 at 15:20
ErnaneErnane
11
11
Giving an Error Would you mind terribly, telling us what error it is giving you old chap
– RiggsFolly
Nov 14 '18 at 15:28
I'm using something like this: somthing like that? If you show us pseudo code, you are just going to get pseudo answers
– RiggsFolly
Nov 14 '18 at 15:36
Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR
– RiggsFolly
Nov 14 '18 at 15:36
No need to use$(function()
inside a click event handler. Won't cause errors but is just redundant
– charlietfl
Nov 14 '18 at 15:52
Sorry buddy, I'm new here in the stack and I'm going to rephrase ... I'm using exactly the above function and I get the error 500 @RiggsFolly
– Ernane
Nov 16 '18 at 10:54
|
show 2 more comments
Giving an Error Would you mind terribly, telling us what error it is giving you old chap
– RiggsFolly
Nov 14 '18 at 15:28
I'm using something like this: somthing like that? If you show us pseudo code, you are just going to get pseudo answers
– RiggsFolly
Nov 14 '18 at 15:36
Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR
– RiggsFolly
Nov 14 '18 at 15:36
No need to use$(function()
inside a click event handler. Won't cause errors but is just redundant
– charlietfl
Nov 14 '18 at 15:52
Sorry buddy, I'm new here in the stack and I'm going to rephrase ... I'm using exactly the above function and I get the error 500 @RiggsFolly
– Ernane
Nov 16 '18 at 10:54
Giving an Error Would you mind terribly, telling us what error it is giving you old chap
– RiggsFolly
Nov 14 '18 at 15:28
Giving an Error Would you mind terribly, telling us what error it is giving you old chap
– RiggsFolly
Nov 14 '18 at 15:28
I'm using something like this: somthing like that? If you show us pseudo code, you are just going to get pseudo answers
– RiggsFolly
Nov 14 '18 at 15:36
I'm using something like this: somthing like that? If you show us pseudo code, you are just going to get pseudo answers
– RiggsFolly
Nov 14 '18 at 15:36
Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR
– RiggsFolly
Nov 14 '18 at 15:36
Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR
– RiggsFolly
Nov 14 '18 at 15:36
No need to use
$(function()
inside a click event handler. Won't cause errors but is just redundant– charlietfl
Nov 14 '18 at 15:52
No need to use
$(function()
inside a click event handler. Won't cause errors but is just redundant– charlietfl
Nov 14 '18 at 15:52
Sorry buddy, I'm new here in the stack and I'm going to rephrase ... I'm using exactly the above function and I get the error 500 @RiggsFolly
– Ernane
Nov 16 '18 at 10:54
Sorry buddy, I'm new here in the stack and I'm going to rephrase ... I'm using exactly the above function and I get the error 500 @RiggsFolly
– Ernane
Nov 16 '18 at 10:54
|
show 2 more comments
1 Answer
1
active
oldest
votes
After a lot of research, I solved the problem as follows:
I created a Regex-type route. This type of route allows you to work with static pages. See example here: https://olegkrivtsov.github.io/using-zend-framework-3-book/html/en/Routing/Regex_Route_Type.html
In the controller, I created the following responsible function for rendering the pages:
public function docAction() !is_readable($filePath))
$this->getResponse()->setStatusCode(404);
return;
$viewModel = new ViewModel([
'page'=>$pageTemplate
]);
$this->layout()->setTemplate('layout/layoutVazio');
$viewModel->setTemplate($pageTemplate);
return $viewModel;
The function that loads the page inside a DIV, in my case, looks like this:
function loadTemplate()
var qtdProdutos = $('#qtdProdutos').val();
if( qtdProdutos == 1 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'pagina']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 2 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'dois_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 3 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'tres_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 4 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'quatro_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303456%2fhow-to-load-an-html-file-inside-a-div-in-the-view-in-zend-framework3%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
After a lot of research, I solved the problem as follows:
I created a Regex-type route. This type of route allows you to work with static pages. See example here: https://olegkrivtsov.github.io/using-zend-framework-3-book/html/en/Routing/Regex_Route_Type.html
In the controller, I created the following responsible function for rendering the pages:
public function docAction() !is_readable($filePath))
$this->getResponse()->setStatusCode(404);
return;
$viewModel = new ViewModel([
'page'=>$pageTemplate
]);
$this->layout()->setTemplate('layout/layoutVazio');
$viewModel->setTemplate($pageTemplate);
return $viewModel;
The function that loads the page inside a DIV, in my case, looks like this:
function loadTemplate()
var qtdProdutos = $('#qtdProdutos').val();
if( qtdProdutos == 1 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'pagina']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 2 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'dois_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 3 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'tres_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 4 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'quatro_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
add a comment |
After a lot of research, I solved the problem as follows:
I created a Regex-type route. This type of route allows you to work with static pages. See example here: https://olegkrivtsov.github.io/using-zend-framework-3-book/html/en/Routing/Regex_Route_Type.html
In the controller, I created the following responsible function for rendering the pages:
public function docAction() !is_readable($filePath))
$this->getResponse()->setStatusCode(404);
return;
$viewModel = new ViewModel([
'page'=>$pageTemplate
]);
$this->layout()->setTemplate('layout/layoutVazio');
$viewModel->setTemplate($pageTemplate);
return $viewModel;
The function that loads the page inside a DIV, in my case, looks like this:
function loadTemplate()
var qtdProdutos = $('#qtdProdutos').val();
if( qtdProdutos == 1 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'pagina']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 2 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'dois_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 3 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'tres_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 4 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'quatro_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
add a comment |
After a lot of research, I solved the problem as follows:
I created a Regex-type route. This type of route allows you to work with static pages. See example here: https://olegkrivtsov.github.io/using-zend-framework-3-book/html/en/Routing/Regex_Route_Type.html
In the controller, I created the following responsible function for rendering the pages:
public function docAction() !is_readable($filePath))
$this->getResponse()->setStatusCode(404);
return;
$viewModel = new ViewModel([
'page'=>$pageTemplate
]);
$this->layout()->setTemplate('layout/layoutVazio');
$viewModel->setTemplate($pageTemplate);
return $viewModel;
The function that loads the page inside a DIV, in my case, looks like this:
function loadTemplate()
var qtdProdutos = $('#qtdProdutos').val();
if( qtdProdutos == 1 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'pagina']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 2 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'dois_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 3 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'tres_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 4 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'quatro_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
After a lot of research, I solved the problem as follows:
I created a Regex-type route. This type of route allows you to work with static pages. See example here: https://olegkrivtsov.github.io/using-zend-framework-3-book/html/en/Routing/Regex_Route_Type.html
In the controller, I created the following responsible function for rendering the pages:
public function docAction() !is_readable($filePath))
$this->getResponse()->setStatusCode(404);
return;
$viewModel = new ViewModel([
'page'=>$pageTemplate
]);
$this->layout()->setTemplate('layout/layoutVazio');
$viewModel->setTemplate($pageTemplate);
return $viewModel;
The function that loads the page inside a DIV, in my case, looks like this:
function loadTemplate()
var qtdProdutos = $('#qtdProdutos').val();
if( qtdProdutos == 1 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'pagina']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 2 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'dois_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 3 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'tres_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
if( qtdProdutos == 4 )
$('#arquivoHtml').load( "<?= $this->url('doc', ['page' => 'quatro_produtos']) ?>", function( response, status, xhr )
if( status == "error" )
var msg = "Desculpe, ocorreu um erro: ";
$('#arquivoHtml').html( msg + xhr.status + " " + xhr.statusText );
);
answered Nov 23 '18 at 12:43
ErnaneErnane
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303456%2fhow-to-load-an-html-file-inside-a-div-in-the-view-in-zend-framework3%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Giving an Error Would you mind terribly, telling us what error it is giving you old chap
– RiggsFolly
Nov 14 '18 at 15:28
I'm using something like this: somthing like that? If you show us pseudo code, you are just going to get pseudo answers
– RiggsFolly
Nov 14 '18 at 15:36
Welcome, to improve your experience on SO please read how to ask an On Topic question, and the Question Check list and the perfect question and how to create a Minimal, Complete and Verifiable Example and TAKE THE TOUR
– RiggsFolly
Nov 14 '18 at 15:36
No need to use
$(function()
inside a click event handler. Won't cause errors but is just redundant– charlietfl
Nov 14 '18 at 15:52
Sorry buddy, I'm new here in the stack and I'm going to rephrase ... I'm using exactly the above function and I get the error 500 @RiggsFolly
– Ernane
Nov 16 '18 at 10:54