I found the way to get query string from this question. But i cannot get the URL inside requested page via ajax.
Example:
<div class="result"></div>
<script>
$(function() {
$.ajax({
url: 'ajax_inner.html',
type: 'GET',
data: 'somename=someval',
dataType: 'html',
success: function(data) {
$('.result.).html(data);
}
});
});
</script>
This is main.html page. And below is ajax_inner.html page.
<p>your query string is: <span class="qsval"></span>.</p>
<script>
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}// getParameterByName
$(function() {
$('.qsval').text(getParameterByName('somename'));
});
</script>
I cannot get anything from query string passed to ajax page.
I tried to alert(location);
inside ajax page but it returns the main.html page.
How to get query string inside ajax page?