Jump to content

publicGenome

New Members
  • Posts

    3
  • Joined

  • Last visited

publicGenome's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi ch0cu3r, Thanks for your reply. Yes, I was getting response with HTML and CSS code. I was calling my function poorly from bootstrap. I fixed that.
  2. Hi There, This is my first post in the forum kindly pardon me if I've violated any forum rules. I've a form, enter something, hit submit, data gets inserted into the database using AJAX POST call. I've been trying to pull data from PHP and display, using AJAX GET. But unfortunately, I get complete web page. Data I'm sending/echo-ing is in JSON. I tried exit() in the PHP "select *", but it didn't help. Below are my code snippets: Form code: <form id="randomInsert" action="<?php echo URL;?>dashboard/xhrInsert" method="post"> <input type="text" id="name_form" name="name_text"/> <input type="submit" id="name-submit" /> </form> Model code: public function xhrGetListings(){ $sth=$this->db->prepare('select * from data'); $sth->setFetchMode(PDO::FETCH_ASSOC); $sth->execute(); echo json_encode($sth->fetchAll()) ; // return $sth->fetchAll(); } Java script code: $.get('dashboard/xhrGetListings',function(data){ console.log(data); alert(JSON.stringify(data)); }); //}); $('#randomInsert').submit(function(){ var url=$(this).attr('action'); var data=$(this).serialize(); $.post(url,data, function(o){ }); return false; });
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.