سؤال

I have a jquery template and an image inside it like this:

<script id="myTmpl" type="text/html">
<div>
<img src="~/Images/myPic.png">
</div>
</script>

I got this error:

GET http://localhost:58864/Test/~/Images/myPic.png 404 (Not Found)

Why does it think my controller (named Test) is the root?

I have no problem placing the image outside the template.

هل كانت مفيدة؟

المحلول

Use this code:

<script id="myTmpl" type="text/html">
<div>
<img src="../Images/myPic.png">
</div>
</script>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top