Hi Team
I am debugging an error log and notice when inserting a data from both client side(javascript and html). Its expecting some additional fields from the database. My connection is fine, but if it says " must include all my table defitions from wishlist or products?
{
"success": false,
"message": "Required data missing."
}
// html code
< class="col-lg-3 col-md-6 col-sm-12 pb-1">
Colorful Stylish Shirt
R200.00
R200.00
/***
@author:Gcobani Mkontwana
@date:11/10/2023
@script handles adding of wishlist to cart.
**/
$(document).ready(function () {
// Initialize wishlist count to 0
let wishlistCount = 0;
// Function to update the wishlist badge count
function updateWishlistBadge() {
$("#wishlist-badge").text(wishlistCount);
}
// Function to open the login modal when the badge is clicked
function openLoginModal() {
$("#wishlistLoginModal").modal("show");
}
// Function to display wishlist items
function displayWishlistItems() {
// Here, you should make an AJAX request to your server to fetch the user's wishlist items.
// Replace the following code with your actual request:
$.ajax({
url: 'get-wishlist-product.php', // Replace with your API endpoint
method: 'GET',
dataType: 'json',
success: function (response) {
if (response.success) {
// The server should return an array of wishlist items.
const wishlistItems = response.items;
// Clear the existing items in the list
$('#wishlistItems').empty();
// Add each item to the list
wishlistItems.forEach(function (item) {
$('#wishlistItems').append(`
Tahir AnsariPosted Oct 13, 2023, 10:12 AM
Make sure that the server-side code (
add-to-wishlist.php) is correctly handling the incoming POST request. Check if it expects and processes theproduct_id,product_name, andproduct_imagedata correctly. Ensure that the server-side code is set up to save this data into the database or perform the necessary actions.please check the below code why are you using l
$.ajax({ l: 'add-to-wishlist.php', // method: 'POST', data: { product_id: productID, product_name: productName, product_image: productImage }, dataType: 'json',
By changing
"l"to"url"in the$.ajaxcall, you should be able to send the AJAX request to the 'add-to-wishlist.php' script correctly. This change should resolve the issue you're facing with your AJAX request.