Reputation:
I know this is simple, but for some reason, I'm not able to process simple right now. I'm sorry if this is a duplicate question. I'm trying to dynamically change text in a website using just a text file, I know AJAX can pull text from a .txt file, but I've never done it before, I've only used xml files. So my question is, how do I pull in the data from the text file and have it formatted correctly? I'm correctly connecting to the file, but I am drawing a blank for some reason and it's not displaying the text on the page. Again, I know this is simple, but I, for some reason, am not able to process this today. Please help. Here's an example of what I'm trying to do:
JavaScript/AJAX
$(document).ready(function(){
$.ajax({
type: "GET",
dataType: "text",
url: "text.txt",
success: function(txt){
console.log("Working");
}
});
})
Text
Hi
Again, I know this is very simple to do, I'm just not registering anything right now. So please, an outside look would help and probably jump start me. Thanks.
Upvotes: -1
Views: 44
Reputation: 547
find
is looking throw children.
If text.txt was <div> <p>Hi</p> </div>
, it would work correct
Upvotes: 0