10/10/2018, 10:42
Giúp mình lấy biến sau dấu #,biến trong ajax hoặc php
Chào các bạn mình đang làm 1 trang web và cần lấy biến như sau:
http://domain.com/#2 hoặc #,2 hoặc #play,2 cái nào cũng được.
Mình muốn code nhận được số 2 nhưng không biết phải viết như thế nào đây.
Bạn nào giúp mình viết với, Có thể bằng ajax hoặc php cũng được ạ.
Mình xin cảm ơn nhiều.
http://domain.com/#2 hoặc #,2 hoặc #play,2 cái nào cũng được.
Mình muốn code nhận được số 2 nhưng không biết phải viết như thế nào đây.
Bạn nào giúp mình viết với, Có thể bằng ajax hoặc php cũng được ạ.
Mình xin cảm ơn nhiều.
Bài liên quan
Bạn giúp mình với.
Cảm ơn bạn nhiều lắm.
alert(str[1]);
ko bít được ko nữa chưa thử bao h
dùng jQuery.url.attr("anchor")
Sau cùng thì cũng tìm đc 1 đoạn code tuy không ưng ý như sau.
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js"></script>
<script type="text/javascript">
loadstatustext = '<center><img src="http://a.imageshack.us/img163/1163/load1.gif"><center>';
//On load page, init the timer which check if the there are anchor changes each 300 ms
$().ready(function(){
setInterval("checkAnchor()", 100);
});
var currentAnchor = null;
//Function which chek if there are anchor changes, if there are, sends the ajax petition
function checkAnchor()
{
//Check if it has changes
if(currentAnchor != document.location.hash){
currentAnchor = document.location.hash;
//if there is not anchor, the loads the default section
if(!currentAnchor)
query = "section=index";
else
{
//Creates the string callback. This converts the url URL/#main&id=2 in URL/?section=main&id=2
var splits = currentAnchor.substring(1).split('&');
//Get the section
var section = splits***91;0***93;;
delete splits***91;0***93;;
//Create the params string
var params = splits.join('&');
var query = "section=" + section + params;
var kiemtra = section;
}
if(kiemtra == 'home')
{
$.get("index/search_menu.php",query, function(data){
$("#menu").html(data);}
);
}
else
{
if(kiemtra == 'related')
{
//Send the petition
$.get("index/related.php",query, function(data){
$("#lienquan").html(data);}
);
}
if(kiemtra == 'Play')
{
//Send the petition
$.get("play.php",query, function(data){
$("#content").html(data);}
);
}
if(kiemtra == 'close')
{
//Send the petition
$.get("noindex.html",query, function(data){
$("#content").html(data);}
);
}
if(kiemtra == 'Page')
{
//Send the petition
$.get("index/search_menu.php",query, function(data){
$("#menu").html(data);}
);
}
}
}
}
</script>
loadstatustext = '<center><img src="http://a.imageshack.us/img163/1163/load1.gif"><center>';
Em muốn khi chưa load xong thì cái hình http://a.imageshack.us/img163/1163/load1.gif sẽ hiển thị lên ạ.
--------------
Bác nào giúp em chèn cái hàm sau vào code trên để khi load code thì nó hiện cái hình loading lên với ạ. Em xin cảm ơn.
loadstatustext = '<center><img src="http://a.imageshack.us/img163/1163/load1.gif"><center>';