Hello,
there is a function which saves and sends post request:
save_car: function(e) {
if (e.keyCode != 13) return;
if (!this.brand.val()) return;
Cars.create({brand: this.brand.val(), color: this.color.val(), max_speed: this.max_speed.val() });
this.brand.val('');
this.color.val('');
this.max_speed.val('');
},
Request URL:http://localhost/backbone/car_list/backend/index.php/welcome/index
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en,lt;q=0.8,en-US;q=0.6,ru;q=0.4,pl;q=0.2
Connection:keep-alive
Content-Length:70
Content-Type:application/json
Cookie:PHPSESSID=5dndo82fup9pi838f9uterrci6; ci_session=a%3A4%3A%7Bs%3A10%3A%22session_id%22%3Bs%3A32%3A%227a7e53ab078672515aec9b4b8a73cb83%22%3Bs%3A10%3A%22ip_address%22%3Bs%3A9%3A%22127.0.0.1%22%3Bs%3A10%3A%22user_agent%22%3Bs%3A50%3A%22Mozilla%2F5.0+%28Windows+NT+6.1%3B+WOW64%29+AppleWebKit%2F53%22%3Bs%3A13%3A%22last_activity%22%3Bi%3A1368858542%3B%7D48f6946a4ed6a07726f1d2790a67993c
Host:localhost
Origin:http://localhost
Referer:http://localhost/backbone/car_list/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
X-Requested-With:XMLHttpRequest
Request Payloadview source
{brand:sad, color:sf, max_speed:sd, order:1, remove:false}
brand: "sad"
color: "sf"
max_speed: "sd"
order: 1
remove: false
So as we see from headers there is post request with various parameters.
Now the php function:
public function index()
{
$this->load->model('Backbone_model');
//$res = $this->Backbone_model->get_all();
if (isset($_GET)) {
echo json_encode($this->Backbone_model->get_all());
}
else if (isset($_POST)) {
echo 'ts';
//SELECT name as brand, address as color, tel as max_speed FROM contacts
$sql = "INSERT INTO contacts (name, address, tel) VALUES (?, ?, ?)";
$this->db->query($sql, array($_POST['brand'], $_POST['color'], $_POST['max_speed'] ));
echo $this->db->last_query();
}
echo 'asss';
print_r($_REQUEST);
}
it returns;
[{"brand":"Darius","color":"maciuleviciaus 30","max_speed":"866612345"},{"brand":"arvydas","color":"zidiku","max_speed":"866"}]asssArray()
so it looks like it see $_GET request. WHy this could be? It returns json and later string 'asss'