Custom popup in magento2












2















I have created a custom popup in list page .. I need to open the popup after 4 sec of every product addtocart.



And auto close the popup after 4 sec.



some time the popup suddenly closed within 4 sec....



How to slove this ...



    $.ajax({
url: BASE_URL + this.options.posturl,
type: "POST",
datatype: "json",
data: {productId: productId},
success: function (response) {
$("#custom-popup").hide();
if (response['content']) {
$("#custom-popup").html(response['content']);
setTimeout(function () {
$("#custom-popup").show();
setInterval(function () {
$("#custom-popup").hide();
}, 4000);
}, 4000);

}
}
});


Thanks.










share|improve this question

























  • please check my answer and let me know if any query.

    – Rohan Hapani
    Jun 23 '18 at 18:56













  • Your answer is same as my question..what is the change???? @Rohan Hapani

    – Mano M
    Jun 25 '18 at 4:19











  • Remove $("#custom-popup").hide(); at success.

    – Rohan Hapani
    Jun 25 '18 at 4:52











  • Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

    – Mano M
    Jun 25 '18 at 5:03


















2















I have created a custom popup in list page .. I need to open the popup after 4 sec of every product addtocart.



And auto close the popup after 4 sec.



some time the popup suddenly closed within 4 sec....



How to slove this ...



    $.ajax({
url: BASE_URL + this.options.posturl,
type: "POST",
datatype: "json",
data: {productId: productId},
success: function (response) {
$("#custom-popup").hide();
if (response['content']) {
$("#custom-popup").html(response['content']);
setTimeout(function () {
$("#custom-popup").show();
setInterval(function () {
$("#custom-popup").hide();
}, 4000);
}, 4000);

}
}
});


Thanks.










share|improve this question

























  • please check my answer and let me know if any query.

    – Rohan Hapani
    Jun 23 '18 at 18:56













  • Your answer is same as my question..what is the change???? @Rohan Hapani

    – Mano M
    Jun 25 '18 at 4:19











  • Remove $("#custom-popup").hide(); at success.

    – Rohan Hapani
    Jun 25 '18 at 4:52











  • Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

    – Mano M
    Jun 25 '18 at 5:03
















2












2








2








I have created a custom popup in list page .. I need to open the popup after 4 sec of every product addtocart.



And auto close the popup after 4 sec.



some time the popup suddenly closed within 4 sec....



How to slove this ...



    $.ajax({
url: BASE_URL + this.options.posturl,
type: "POST",
datatype: "json",
data: {productId: productId},
success: function (response) {
$("#custom-popup").hide();
if (response['content']) {
$("#custom-popup").html(response['content']);
setTimeout(function () {
$("#custom-popup").show();
setInterval(function () {
$("#custom-popup").hide();
}, 4000);
}, 4000);

}
}
});


Thanks.










share|improve this question
















I have created a custom popup in list page .. I need to open the popup after 4 sec of every product addtocart.



And auto close the popup after 4 sec.



some time the popup suddenly closed within 4 sec....



How to slove this ...



    $.ajax({
url: BASE_URL + this.options.posturl,
type: "POST",
datatype: "json",
data: {productId: productId},
success: function (response) {
$("#custom-popup").hide();
if (response['content']) {
$("#custom-popup").html(response['content']);
setTimeout(function () {
$("#custom-popup").show();
setInterval(function () {
$("#custom-popup").hide();
}, 4000);
}, 4000);

}
}
});


Thanks.







magento2.2 jquery






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 mins ago







Mano M

















asked Jun 23 '18 at 11:17









Mano MMano M

799217




799217













  • please check my answer and let me know if any query.

    – Rohan Hapani
    Jun 23 '18 at 18:56













  • Your answer is same as my question..what is the change???? @Rohan Hapani

    – Mano M
    Jun 25 '18 at 4:19











  • Remove $("#custom-popup").hide(); at success.

    – Rohan Hapani
    Jun 25 '18 at 4:52











  • Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

    – Mano M
    Jun 25 '18 at 5:03





















  • please check my answer and let me know if any query.

    – Rohan Hapani
    Jun 23 '18 at 18:56













  • Your answer is same as my question..what is the change???? @Rohan Hapani

    – Mano M
    Jun 25 '18 at 4:19











  • Remove $("#custom-popup").hide(); at success.

    – Rohan Hapani
    Jun 25 '18 at 4:52











  • Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

    – Mano M
    Jun 25 '18 at 5:03



















please check my answer and let me know if any query.

– Rohan Hapani
Jun 23 '18 at 18:56







please check my answer and let me know if any query.

– Rohan Hapani
Jun 23 '18 at 18:56















Your answer is same as my question..what is the change???? @Rohan Hapani

– Mano M
Jun 25 '18 at 4:19





Your answer is same as my question..what is the change???? @Rohan Hapani

– Mano M
Jun 25 '18 at 4:19













Remove $("#custom-popup").hide(); at success.

– Rohan Hapani
Jun 25 '18 at 4:52





Remove $("#custom-popup").hide(); at success.

– Rohan Hapani
Jun 25 '18 at 4:52













Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

– Mano M
Jun 25 '18 at 5:03







Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

– Mano M
Jun 25 '18 at 5:03












1 Answer
1






active

oldest

votes


















0














Try to use this code :



$.ajax({
url: BASE_URL + this.options.posturl,
type: "POST",
datatype: "json",
data: {
productId: productId
},
success: function(response) {

if (response['content']) {
$("#custom-popup").html(response['content']);
setTimeout(function() {
$("#custom-popup").show();
setInterval(function() {
$("#custom-popup").hide();
}, 4000);
}, 4000);
}
}
});





share|improve this answer
























  • Your answer is same as my question..what is the change???? @Rohan Hapani

    – Mano M
    Jun 25 '18 at 4:19











  • Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

    – Mano M
    Jun 25 '18 at 5:04











  • No. It will be useful for after 4 sec hide popup. Please check in diff checker you get idea about what you want to do.

    – Rohan Hapani
    Jun 25 '18 at 6:07











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f231128%2fcustom-popup-in-magento2%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









0














Try to use this code :



$.ajax({
url: BASE_URL + this.options.posturl,
type: "POST",
datatype: "json",
data: {
productId: productId
},
success: function(response) {

if (response['content']) {
$("#custom-popup").html(response['content']);
setTimeout(function() {
$("#custom-popup").show();
setInterval(function() {
$("#custom-popup").hide();
}, 4000);
}, 4000);
}
}
});





share|improve this answer
























  • Your answer is same as my question..what is the change???? @Rohan Hapani

    – Mano M
    Jun 25 '18 at 4:19











  • Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

    – Mano M
    Jun 25 '18 at 5:04











  • No. It will be useful for after 4 sec hide popup. Please check in diff checker you get idea about what you want to do.

    – Rohan Hapani
    Jun 25 '18 at 6:07
















0














Try to use this code :



$.ajax({
url: BASE_URL + this.options.posturl,
type: "POST",
datatype: "json",
data: {
productId: productId
},
success: function(response) {

if (response['content']) {
$("#custom-popup").html(response['content']);
setTimeout(function() {
$("#custom-popup").show();
setInterval(function() {
$("#custom-popup").hide();
}, 4000);
}, 4000);
}
}
});





share|improve this answer
























  • Your answer is same as my question..what is the change???? @Rohan Hapani

    – Mano M
    Jun 25 '18 at 4:19











  • Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

    – Mano M
    Jun 25 '18 at 5:04











  • No. It will be useful for after 4 sec hide popup. Please check in diff checker you get idea about what you want to do.

    – Rohan Hapani
    Jun 25 '18 at 6:07














0












0








0







Try to use this code :



$.ajax({
url: BASE_URL + this.options.posturl,
type: "POST",
datatype: "json",
data: {
productId: productId
},
success: function(response) {

if (response['content']) {
$("#custom-popup").html(response['content']);
setTimeout(function() {
$("#custom-popup").show();
setInterval(function() {
$("#custom-popup").hide();
}, 4000);
}, 4000);
}
}
});





share|improve this answer













Try to use this code :



$.ajax({
url: BASE_URL + this.options.posturl,
type: "POST",
datatype: "json",
data: {
productId: productId
},
success: function(response) {

if (response['content']) {
$("#custom-popup").html(response['content']);
setTimeout(function() {
$("#custom-popup").show();
setInterval(function() {
$("#custom-popup").hide();
}, 4000);
}, 4000);
}
}
});






share|improve this answer












share|improve this answer



share|improve this answer










answered Jun 23 '18 at 18:55









Rohan HapaniRohan Hapani

6,11721662




6,11721662













  • Your answer is same as my question..what is the change???? @Rohan Hapani

    – Mano M
    Jun 25 '18 at 4:19











  • Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

    – Mano M
    Jun 25 '18 at 5:04











  • No. It will be useful for after 4 sec hide popup. Please check in diff checker you get idea about what you want to do.

    – Rohan Hapani
    Jun 25 '18 at 6:07



















  • Your answer is same as my question..what is the change???? @Rohan Hapani

    – Mano M
    Jun 25 '18 at 4:19











  • Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

    – Mano M
    Jun 25 '18 at 5:04











  • No. It will be useful for after 4 sec hide popup. Please check in diff checker you get idea about what you want to do.

    – Rohan Hapani
    Jun 25 '18 at 6:07

















Your answer is same as my question..what is the change???? @Rohan Hapani

– Mano M
Jun 25 '18 at 4:19





Your answer is same as my question..what is the change???? @Rohan Hapani

– Mano M
Jun 25 '18 at 4:19













Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

– Mano M
Jun 25 '18 at 5:04





Can i remove these lines in my code ? setInterval(function () { $("#custom-popup").hide(); }, 4000);

– Mano M
Jun 25 '18 at 5:04













No. It will be useful for after 4 sec hide popup. Please check in diff checker you get idea about what you want to do.

– Rohan Hapani
Jun 25 '18 at 6:07





No. It will be useful for after 4 sec hide popup. Please check in diff checker you get idea about what you want to do.

– Rohan Hapani
Jun 25 '18 at 6:07


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f231128%2fcustom-popup-in-magento2%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

What other Star Trek series did the main TNG cast show up in?

Berlina muro

Berlina aerponto