Jump to content

Search the Community

Showing results for tags 'ajax;'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi I would like to use my php class to be called from ajax but i don't get it to work propery This is my main class (part) class USER { private $db; function __construct($DB_con) { $this->db = $DB_con; } public function delItem($id_itens){ 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()); return array('status' => 'error', 'message' => 'Problema ao remover este item...'); } else { return array('status' => 'success', 'message' => 'O registo foi removido com sucesso...'); } } catch (PDOException $e) { echo $e->getMessage(); } } And in my main file <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); include_once 'dbconfig.php'; $user_role = $_SESSION['user_role']; if (!$user->is_loggedin()) { $user->redirect('index.php'); } //include 'menu_admin.php'; $user_id = $_SESSION['user_session']; ?> <script> $(function () { $('#myFormSubmit').click(function (e) { e.preventDefault(); var item = $('#id_itens').val(); var delItem = "delItem"; $.ajax({ url: '<?php echo $user->delitem($delItem); ?>', type: 'POST', data: {'delItem': delItem, 'item': item}, success: function (response) { if (response.status === 'success') { 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); }); } } }); }); }); </script> And i can't get this working properly, do i miss something? Thanks
×
×
  • 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.