javascript - var = Variable + 'String' -
i'm trying dynamically include text file page using jquery, can't seem work variable filepath. tried title.txt instead of passing variable , worked, $title + '.txt' didn't work.
what doing wrong?
works:
$(function () { $("#list").load('test.txt'); });
attempt 1:
$(function () { var $title = document.getelementsbytagname("title")[0].innerhtml, $url = $title + '.txt'; $("#list").load($url); });
attempt 2:
$(function () { var $title = document.getelementsbytagname("title")[0].innerhtml, $ext = '.txt', $url = $title + $ext; $("#list").load($url); });
attempt 3:
$(function () { var $title = document.getelementsbytagname("title")[0].innerhtml, $("#list").load($title + '.txt'); });
try this, per comment in chat:
$(function () { var $title = encodeuri( $('title').text() ), $url = $title + '.txt'; $("#list").load($url); });
Comments
Post a Comment