So I have a simple setup going here where I load up a file (A blender .obj file) and display it. Then I call this function:
function parseFile(){
var fileText = $('#file').html();
var fileLine = fileText.split("\r\n");
$('#file').html(fileLine[5]);
}
Which should make it so it displays the 6th line of the file, but it still displays the whole file. How do I make it split the lines like they are in the actual file?
Edit: Just so everyone know’s I’m loading the file like this: $('#file').load('model.obj');
The call to
.load()is asynchronous. The method will return, but the content will be available somewhen in the future. You’ll need to use a callback:Or more narrative, using the deferred interface:
If you need/want to parse the server response anyway, it might be a better to use
$.ajax()directly instead of loading it into ainnerHTMLand reading from there… You even could use a dedicateddataFilterfor the blender.obj file type.