1
Firstly,to avoid any confusion,update your URL as :
url(r'^stat_details/(?P<code>[-\w]+)/$',views.Listing.as_view(),name='stat_details'),
And then render your url just as a string like this :
<script>
$(document).ready(function(){
var code = your_code;
var url = "/stat_details/"+ code;
alert(url);
$.ajax({
url: url,
success:function(result){
populateTable(result.data.m_data);
},
error:function(xhr){
alert("Fail"+ xhr.status+ " "+ xhr.responseText);
}
});
});
</script>
You don’t need to complicate the URL request process and please don’t forget the first / in var url = “/stat_details/”+ code;
And if the method is post,then you should also mention it. Thanks.
Source:stackexchange.com