I have a simple controller function that deletes a database record (the model function is used for this). I have a link to this in one of my views (e.g. http://www.example.com/item/delete/3 ) and Im using jQuery displays a confirmation dialog to make sure that the user really wants to delete it . Everything is fine. However, if you simply enter this URL in your browser, the item will be deleted without warning.
Is there a way to handle this either in how I code the controller function or in the model?
HTTP.
function delete() { if ($id = $this->input->post('id')) { $this->item_model->delete_item($id); } }
JQuery HTTP-.
$.ajax({ type: 'POST', url: 'item/delete', data: {id:item_id} });
, URL- -.
, ( CI Forum).
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class SomeModel extends Model { // model code } ?>
, CI .
, , , ..
function _delete($id) { ...delete code goes here... }
AJAX? , POST GET, .
GET, , , , .
, 100% .
Source: https://habr.com/ru/post/1740034/More articles:Lock javascript lock - javascriptmono --aot with MinGW: неизвестный псевдооператор: `.local ' - .netCan base64 encoding be applied to multibyte utf-8 characters? - base64How to make a connection that removes values? - sqlReadObject DataContractJsonSerializer exception - jsonКак это лучше написать? - c#PHP array ordering - sortingasp pages and paypal button - asp.netFunction Testing on Netbeans 6.8 - user-interfaceExamples of Tri20 monotouch / btouch models? - iphoneAll Articles