AJAX - GET data not being recieved from PHP
Posted: Thu Oct 29, 2015 1:41 pm
Hi Members,
Brief about application:
- Enter anything in field. That gets feed into database using AJAX-post.
- I'd like to display what is being sent to the database using AJAX-get
# I've been able to send data correctly, it's inserted into database.
# When get call is made I'm able to see all the rows pulled up. But somehow I don't enter into the function. I tried with alert.
Have stuck here past couple of hours now.
this prints all the rows pulled in json format. But for some reason I do not get flow back to the $.get in java script.
* jQuery JavaScript Library v1.11.3
Neither alert in the ajax-get request helps.

Brief about application:
- Enter anything in field. That gets feed into database using AJAX-post.
- I'd like to display what is being sent to the database using AJAX-get
# I've been able to send data correctly, it's inserted into database.
# When get call is made I'm able to see all the rows pulled up. But somehow I don't enter into the function. I tried with alert.
Have stuck here past couple of hours now.
Code: Select all
$(function(){
$.get('dashboard/xhrGetListings',function(o){
//get the data backk..
alert("hello"); //no messgae is being displayed..
//
},'json');
$('#randomInsert').submit(function(){ //this function inserts into database
var url=$(this).attr('action');
var data=$(this).serialize();
$.post(url,data, function(o){
});
return false;
});
}
);
Code: Select all
public function xhrGetListings(){ //function called from AJAX
$sth=$this->db->prepare('select * from data'); //pull data
$sth->setFetchMode(PDO::FETCH_ASSOC);
$sth->execute();
echo json_encode($sth->fetchAll()) ;
// return $sth->fetchAll();
}
* jQuery JavaScript Library v1.11.3
Neither alert in the ajax-get request helps.