-2
我要動態地從行書位置如何檢測當前的Java腳本代碼的文件名乳寧
例如發送當前的文件名:
的index.php
<html>
<head>
<script src="script.js"></scritp>
</head>
<body>
...
</body>
</html>
的script.js
$(function(){
$data = [];
$.getJSON("data.php",{ajax_sending_filename : FILE_NAME},
function(response){
$data = jQuery.parseJSON(response);
});
});
我需要動態獲取當前文件名並將其替換爲FILE_NAME:
$.getJSON("data.php",{ajax_sending_filename : 'index' //FILE_NAME},
請提出一種適用於所有瀏覽器的方法。
感謝您的幫助:-)
編輯:
,因爲使用MVC和地點,按文件名不同,我cant't使用windows.location。
'window.location' – hjpotter92
頁面URL是什麼樣的? – lshettyl
@ hjpotter92我不能使用windows.location,因爲使用mvc和位置diffrent by filename –