I am trying to send data to server and get back some data in json format using ajax, what i've tried
if (!empty($_REQUEST['data1'])) {
$dt = $_REQUEST['data1'];
$arr = [1,2,3];
header("Content-Type: application/json", true);
echo json_encode($arr);
}
<script>
jQuery(document).ready(function(){
jQuery('.selectpicker').selectpicker();
jQuery('#datepick').datepicker({
format: "dd/mm/yyyy"
});
jQuery('.client_list a').click(function() {
alert(jQuery(this).text());
var data={};
data['client_name']=jQuery(this).text();
load_data(data,window.location.pathname);
});
});
var load_data=function(data,url,selector){
jQuery.post(url,{'data1':data})
.done(function(result){
console.log(result+"Hello");
})
.fail(function( jqXHR, textStatus) {
console.log( "failed due:"+ textStatus);
});
};
</script>
I'm getting parseerror why is is this
UPDATE
my php script and jquery are in one file and my url is window.location.pathname inside getJSON