Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within PHP
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Spring Boot in Practice
this week in the
Spring
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
Jeanne Boyarsky
Paul Clapham
Sheriffs:
Liutauras Vilda
Henry Wong
Devaka Cooray
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Al Hobbs
Carey Brown
Bartenders:
Piet Souris
Mikalai Zaikin
Himai Minh
Forum:
PHP
Ajax call php function class
Gil Carvalho
Ranch Hand
Posts: 80
posted 6 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
Can someone help me with this code, i can't call my function from ajax
This is the ajax code
<script> $(function () { $('#myFormSubmit').click(function (e) { e.preventDefault(); var item = $('#id_itens').val(); $.ajax({ url: 'http://localhost/esmaior_biblio/class.user.php', type: 'POST', data: {action: 'delItem',item: item}, success: function (response) { if (response.status === 'success') { console.log( "it's working" ); console.log("success"); $("#myModal").modal('hide'); $('#respostas .modal-title').html('Sucesso'); $('#respostas .modal-body').html('Informação: ' + response.message); $('#respostas').modal('show'); $('#respostas').on('hidden.bs.modal', function () { window.location.reload(true); }); } console.log( "it is not working" ); } }); }); }); </script> In my console i have console.log( "it is not working" ); any help?
and this is my class function
class USER { private $db; function __construct($DB_con) { $this->db = $DB_con; } public function delItem(){ $id_itens = filter_input(INPUT_POST, 'item'); try { $sql = 'DELETE FROM `esmaior_biblioteca`.`item` WHERE `id_itens` = :me'; $stmt = $this->db->prepare($sql); $stmt->bindValue(':me', $id_itens, PDO::PARAM_INT); if (!$stmt->execute()) { print_r($stmt->errorInfo()); json_encode(array('status' => 'error', 'message' => 'Problema ao remover este item...')); } else { json_encode(array('status' => 'success', 'message' => 'O registo foi removido com sucesso...')); } } catch (PDOException $e) { echo $e->getMessage(); } }
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Selector with multiples erro
problem php with mysql
PHP wont grab POST
Undefined index
Accessing a file system HSQLDB through PHP
More...