I want cha开发者_JAVA技巧nge my site in ajax that google crawlable.
With URL :
Http://mysite/artices/view/#!/1234
How i can get 1234 in above URL
I think you're asking for a regex, so I'll give you one:
/#!\/(\d+)/
The first (and only) backreference is the number you want.
Hi You can't send string after "#" to server, this is the way you can do it, I have created full working example for you:
<?php
if($_POST['hello'])
{
print_r($_POST);
echo '<br>';
echo $_SERVER['REQUEST_URI'] . '<br>';
die();
}
?>
<html>
<head>
<script type="text/javascript" language="javascript" src="jquery.js" ></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('#look').click(function()
{
var url = 'http://localhost/tests/form.php#cool=1';
var paramAfter = url.split('#')[1];
$.post('http://localhost/tests/form.php#cool=1', "hello=1¶mAfter=" + encodeURIComponent(paramAfter), function(data)
{
$('#content').html(data);
});
return false;
});
});
</script>
</head>
<body>
<a href="#" id="look">Click me</a>
<div id="content">
No content
</div>
</body>
</html>
精彩评论