0

I know this maybe a simple problem for some, but i really don´t know what´s the problem here. Inside a simple for loop i have this:

for (i = 0; i < r.foto.length; i++) 
{
  let slide = '<a href=../img/'+ r.foto[i] +'>' + '<img src=../img/thumb/'+ r.fotoThumbArray[i]+'>' + '</a>';
}

This is suppose to get photos that i have in my database, and the strange error that appears is in the console:

GET http://basedados.test/img/thumb/thumbqZSxpYVJevWz0PMR.jpeg%22 404 (Not Found)

I don´t understand why it appears that %22 in the end of the GET method, any guesses?

Regards

4
  • 6
    %22 is ". So, it sounds like you have an extra " in your foto[i] or in your fotoThumbArray[i]. Mind logging the array and posting the result? Thanks. Commented Oct 18, 2018 at 13:07
  • To add to briosheje see HTML URL Encoding for more information about characters like %22. Commented Oct 18, 2018 at 13:08
  • 1
    you have to write href="", the " are missing in your string Commented Oct 18, 2018 at 13:09
  • r.foto.reduce((tmp, x, xi) => `<a href=../img/${x}><img src=../img/thumb/${r.fotoThumbArray[xi]}></a>`, ''); Commented Oct 18, 2018 at 13:23

3 Answers 3

1

%22 is due to URL Encoding of characters that do not fall under the ASCII Character set. URLs can only be sent over the internet by converting any such characters by encoding them.

Refer this:- https://www.w3schools.com/tags/ref_urlencode.asp

Sign up to request clarification or add additional context in comments.

Comments

0

try this:

for (i = 0; i < r.foto.length; i++) 
{
  let slide = '<a href="../img/'+ r.foto[i] +'">' + '<img src="../img/thumb/'+ r.fotoThumbArray[i]+'">' + '</a>';
}

1 Comment

This would not change anything, because the extra quote mark is in r.fotoThumbArray[i]. Also, answers which explain how their changes are meant to fix the problem are better than those which simply show code.
0

Thanks everyone for your help, briosheje was right, i was saving the image with extra characters.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.