Reputation: 31
I want to use the ()Load method. I have done it without a problem on PHP but now I want to do the same on ASP.net.
<script>
$(document).ready(function () {
$("#btn").click(function () {
$("#test").load("footershop.txt")
});
});
</script>
<section class="shop">
<footer>
<img src="@Url.Content("~/Images/klader.jpg")" alt="klader">
<div id="test" >
<p class="shoptext">text</p>
</div><br />
<button id="btn">Mejla oss</button>
</footer>
</section>
Here is my code in ASP.net. I put the "footershop.txt" in the App_Data folder. It does not show up. Where should I put the textfile in ASP?
Upvotes: 3
Views: 117
Reputation: 5962
you can use $.ajax instead of load
to show the textfile content in the div. The txt file should be in the same directory path for the below code to work else you have to specify the actual path at the url
property
<script>
$(document).ready(function () {
$("#btn").click(function () {
$.ajax({
url : "footershop.txt",
dataType: "text",
success : function (data) {
$("#test").html(data);
}
});
});
});
</script>
you should be testing it from a server not from local system as there might access issues in local to read the txt file.
Upvotes: 2