Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  66] [ 5]  / answers: 1 / hits: 16272  / 10 Years ago, wed, june 11, 2014, 12:00:00

I have a problem with jquery syntax in an url link:



this is the link i am getting (englisch):




...myaccount/?lang=en%2Fprint-order%2F2067%2F&print-order-type=receipt




this is the german link:




...myaccount/print-order/2067/?print-order-type=receipt




the problem now is, that the link looks ok in my browser




myaccount/print-order/2067/?print-order-type=receipt




but actually there's always a %2F instead of a / inside the link when I copy it which leads to the problem of getting an 404.



When I manually replace %2F the link works.



Where is the problem? Any idea to fix this?



The code below comes from woocommerce/templates/myaccount/my-orders.php



if ($actions) { foreach ( $actions as $key => $action ) { echo '<a
href=' . esc_url( $action['url'] ) . ' class=button ' .
sanitize_html_class( $key ) . '>' . esc_html( $action['name'] ) .
'</a>'; }


It generates the Print button on the my orders page. I am using mqtranslate german/englisch. In the german version everything works- the links are correct, ony when i switch the language there are %2f instead of /. But also only after the first part (until myaccount/) - because some / are correctly encoded.



Also in the english version it's a & before print-order-type=receipt instead of a ?.


More From » php

 Answers
4

Use decodeURIComponent on the copied value:



decodeURIComponent('myaccount/?lang=en%2Fprint-order%2F2067%2F?print-order-type=receipt')


http://jsfiddle.net/7hySU/


[#70620] Monday, June 9, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dominics

Total Points: 424
Total Questions: 99
Total Answers: 107

Location: South Korea
Member since Fri, Sep 11, 2020
4 Years ago
dominics questions
Wed, Apr 6, 22, 00:00, 2 Years ago
Thu, Jan 13, 22, 00:00, 2 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
;