Decode href URL link and Redirect Page with Vue.js after POST





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I have an example Vue.js setup of two pages. A list of products and then an order form.



https://listorder.netlify.com



ISSUE 1 - The URL passed from products to order page input gets encoded. I have tried to decode with decodeURI() but it still outputs encoded.



<a class="btn btn-primary btn-pill" v-bind:href="'order.html?product=' + decodeURI(item.title) + '&' ?price=' + decodeURI(item.price)"  style="color:white;">Buy Now</a>


ISSUE 2 - After POST has completed, I need to redirect to a Paypal page appending data from the "Price" field on the order page. Not sure whether Vue will be required here or to add into the existing javascript.



Paypal page to redirect to https://www.paypal.me/wereallcatshere/USD then append the "price" field



JAVASCRIPT



form.addEventListener('submit', e => {
e.preventDefault()
showLoadingIndicator()
fetch(scriptURL, { method: 'POST', body: new FormData(form) })
.then(response => showSuccessMessage(response))
.catch(error => showErrorMessage(error))
})

function showSuccessMessage(response) {
console.log('Success!', response)
setTimeout(() => {
successMessage.classList.remove('is-hidden')
loading.classList.add('is-hidden')
}, 500)
}


VUE



<script type="text/javascript">
const app = new Vue({
el: '#app',
data: {
items:
},
created: function () {
fetch('listorder.json')
.then(resp => resp.json())
.then(items => {
this.items = items;
})
},
methods: {
redirect: function () {
window.location.href = "https://www.paypal.me/wereallcatshere/USD" + item.price;
}
}
});









share|improve this question

























  • please explain the scenario and what you want to get and what are you getting?

    – Boussadjra Brahim
    Nov 16 '18 at 14:22













  • Hi BB, Currently getting encoded urls, I want these to be decoded. Secondly, I want to redirect after POST has completed to a external URL with the "item.price" appended to that URL. Please check the demo site to see the current encoded url and redirect issue

    – Gracie
    Nov 16 '18 at 14:46











  • First off it's advisable to use Vue methods to handle form validations and submissions. Second you should avoid having to use native JavaScript event handlers in Vue components since you're using the Vue loader. Read more here vuejs.org/v2/cookbook/form-validation.html

    – Roj
    Nov 16 '18 at 15:22




















2















I have an example Vue.js setup of two pages. A list of products and then an order form.



https://listorder.netlify.com



ISSUE 1 - The URL passed from products to order page input gets encoded. I have tried to decode with decodeURI() but it still outputs encoded.



<a class="btn btn-primary btn-pill" v-bind:href="'order.html?product=' + decodeURI(item.title) + '&' ?price=' + decodeURI(item.price)"  style="color:white;">Buy Now</a>


ISSUE 2 - After POST has completed, I need to redirect to a Paypal page appending data from the "Price" field on the order page. Not sure whether Vue will be required here or to add into the existing javascript.



Paypal page to redirect to https://www.paypal.me/wereallcatshere/USD then append the "price" field



JAVASCRIPT



form.addEventListener('submit', e => {
e.preventDefault()
showLoadingIndicator()
fetch(scriptURL, { method: 'POST', body: new FormData(form) })
.then(response => showSuccessMessage(response))
.catch(error => showErrorMessage(error))
})

function showSuccessMessage(response) {
console.log('Success!', response)
setTimeout(() => {
successMessage.classList.remove('is-hidden')
loading.classList.add('is-hidden')
}, 500)
}


VUE



<script type="text/javascript">
const app = new Vue({
el: '#app',
data: {
items:
},
created: function () {
fetch('listorder.json')
.then(resp => resp.json())
.then(items => {
this.items = items;
})
},
methods: {
redirect: function () {
window.location.href = "https://www.paypal.me/wereallcatshere/USD" + item.price;
}
}
});









share|improve this question

























  • please explain the scenario and what you want to get and what are you getting?

    – Boussadjra Brahim
    Nov 16 '18 at 14:22













  • Hi BB, Currently getting encoded urls, I want these to be decoded. Secondly, I want to redirect after POST has completed to a external URL with the "item.price" appended to that URL. Please check the demo site to see the current encoded url and redirect issue

    – Gracie
    Nov 16 '18 at 14:46











  • First off it's advisable to use Vue methods to handle form validations and submissions. Second you should avoid having to use native JavaScript event handlers in Vue components since you're using the Vue loader. Read more here vuejs.org/v2/cookbook/form-validation.html

    – Roj
    Nov 16 '18 at 15:22
















2












2








2








I have an example Vue.js setup of two pages. A list of products and then an order form.



https://listorder.netlify.com



ISSUE 1 - The URL passed from products to order page input gets encoded. I have tried to decode with decodeURI() but it still outputs encoded.



<a class="btn btn-primary btn-pill" v-bind:href="'order.html?product=' + decodeURI(item.title) + '&' ?price=' + decodeURI(item.price)"  style="color:white;">Buy Now</a>


ISSUE 2 - After POST has completed, I need to redirect to a Paypal page appending data from the "Price" field on the order page. Not sure whether Vue will be required here or to add into the existing javascript.



Paypal page to redirect to https://www.paypal.me/wereallcatshere/USD then append the "price" field



JAVASCRIPT



form.addEventListener('submit', e => {
e.preventDefault()
showLoadingIndicator()
fetch(scriptURL, { method: 'POST', body: new FormData(form) })
.then(response => showSuccessMessage(response))
.catch(error => showErrorMessage(error))
})

function showSuccessMessage(response) {
console.log('Success!', response)
setTimeout(() => {
successMessage.classList.remove('is-hidden')
loading.classList.add('is-hidden')
}, 500)
}


VUE



<script type="text/javascript">
const app = new Vue({
el: '#app',
data: {
items:
},
created: function () {
fetch('listorder.json')
.then(resp => resp.json())
.then(items => {
this.items = items;
})
},
methods: {
redirect: function () {
window.location.href = "https://www.paypal.me/wereallcatshere/USD" + item.price;
}
}
});









share|improve this question
















I have an example Vue.js setup of two pages. A list of products and then an order form.



https://listorder.netlify.com



ISSUE 1 - The URL passed from products to order page input gets encoded. I have tried to decode with decodeURI() but it still outputs encoded.



<a class="btn btn-primary btn-pill" v-bind:href="'order.html?product=' + decodeURI(item.title) + '&' ?price=' + decodeURI(item.price)"  style="color:white;">Buy Now</a>


ISSUE 2 - After POST has completed, I need to redirect to a Paypal page appending data from the "Price" field on the order page. Not sure whether Vue will be required here or to add into the existing javascript.



Paypal page to redirect to https://www.paypal.me/wereallcatshere/USD then append the "price" field



JAVASCRIPT



form.addEventListener('submit', e => {
e.preventDefault()
showLoadingIndicator()
fetch(scriptURL, { method: 'POST', body: new FormData(form) })
.then(response => showSuccessMessage(response))
.catch(error => showErrorMessage(error))
})

function showSuccessMessage(response) {
console.log('Success!', response)
setTimeout(() => {
successMessage.classList.remove('is-hidden')
loading.classList.add('is-hidden')
}, 500)
}


VUE



<script type="text/javascript">
const app = new Vue({
el: '#app',
data: {
items:
},
created: function () {
fetch('listorder.json')
.then(resp => resp.json())
.then(items => {
this.items = items;
})
},
methods: {
redirect: function () {
window.location.href = "https://www.paypal.me/wereallcatshere/USD" + item.price;
}
}
});






javascript html vue.js vuejs2 vue-component






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 15:12







Gracie

















asked Nov 16 '18 at 13:41









GracieGracie

198110




198110













  • please explain the scenario and what you want to get and what are you getting?

    – Boussadjra Brahim
    Nov 16 '18 at 14:22













  • Hi BB, Currently getting encoded urls, I want these to be decoded. Secondly, I want to redirect after POST has completed to a external URL with the "item.price" appended to that URL. Please check the demo site to see the current encoded url and redirect issue

    – Gracie
    Nov 16 '18 at 14:46











  • First off it's advisable to use Vue methods to handle form validations and submissions. Second you should avoid having to use native JavaScript event handlers in Vue components since you're using the Vue loader. Read more here vuejs.org/v2/cookbook/form-validation.html

    – Roj
    Nov 16 '18 at 15:22





















  • please explain the scenario and what you want to get and what are you getting?

    – Boussadjra Brahim
    Nov 16 '18 at 14:22













  • Hi BB, Currently getting encoded urls, I want these to be decoded. Secondly, I want to redirect after POST has completed to a external URL with the "item.price" appended to that URL. Please check the demo site to see the current encoded url and redirect issue

    – Gracie
    Nov 16 '18 at 14:46











  • First off it's advisable to use Vue methods to handle form validations and submissions. Second you should avoid having to use native JavaScript event handlers in Vue components since you're using the Vue loader. Read more here vuejs.org/v2/cookbook/form-validation.html

    – Roj
    Nov 16 '18 at 15:22



















please explain the scenario and what you want to get and what are you getting?

– Boussadjra Brahim
Nov 16 '18 at 14:22







please explain the scenario and what you want to get and what are you getting?

– Boussadjra Brahim
Nov 16 '18 at 14:22















Hi BB, Currently getting encoded urls, I want these to be decoded. Secondly, I want to redirect after POST has completed to a external URL with the "item.price" appended to that URL. Please check the demo site to see the current encoded url and redirect issue

– Gracie
Nov 16 '18 at 14:46





Hi BB, Currently getting encoded urls, I want these to be decoded. Secondly, I want to redirect after POST has completed to a external URL with the "item.price" appended to that URL. Please check the demo site to see the current encoded url and redirect issue

– Gracie
Nov 16 '18 at 14:46













First off it's advisable to use Vue methods to handle form validations and submissions. Second you should avoid having to use native JavaScript event handlers in Vue components since you're using the Vue loader. Read more here vuejs.org/v2/cookbook/form-validation.html

– Roj
Nov 16 '18 at 15:22







First off it's advisable to use Vue methods to handle form validations and submissions. Second you should avoid having to use native JavaScript event handlers in Vue components since you're using the Vue loader. Read more here vuejs.org/v2/cookbook/form-validation.html

– Roj
Nov 16 '18 at 15:22














0






active

oldest

votes












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339038%2fdecode-href-url-link-and-redirect-page-with-vue-js-after-post%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339038%2fdecode-href-url-link-and-redirect-page-with-vue-js-after-post%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

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python