Posted on 28 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
I have 2 pages, practice.php and addtocart.php. In practice.php, I gather info from a form and send the info using AJAX to addtocart.php. This page then connects to the database and inserts my values. However I am not receiving any response from addtocart.php and no data is being inserted in the database.
I have been trying to figure out the problem but cannot seem to find it. Please help.
practice.php
//form from which addtocart is being called<form id="mehendicones">Color:<input list="mehendi_color"class="mehendi_color"id="mehendi_color1"><datalist id="mehendi_color"><option value="Black"><option value="White"><option value="Brown"><option value="Dark Red">datalist> <p id="price">17p>Quantity<input type="number" min="5" max="15"id="quantity_mehendi_color" step="1"><input type="submit" value="ADD TO CART" style="text-align:center;"
onclick="addtocart()">form>function addtocart(){var request =newXMLHttpRequest();var url ="addtocart.php";
request.open("POST", url,true);
request.setRequestHeader("Content-Type","application/x-www-form-
urlencoded");
request.onreadystatechange =function(){if(request.readyState ===4&& request.status ===200){
alert(request.response);}};var pdetails ="mehendi cones";var pquantity = document.forms["mehendicones"]["quantity_mehendi_color"].value;var pcolor = document.forms["mehendicones"]["mehendi_color1"].value;varprice= document.getElementById("price").innerHTML;var data =({"pdetails": pdetails,"pquantity": pquantity,"pcolor": pcolor,"price":price});
request.send(data);}
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that
you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice
sessions to improve your knowledge and scores.
manpreet
Best Answer
2 years ago
I have 2 pages, practice.php and addtocart.php. In practice.php, I gather info from a form and send the info using AJAX to addtocart.php. This page then connects to the database and inserts my values. However I am not receiving any response from addtocart.php and no data is being inserted in the database.
I have been trying to figure out the problem but cannot seem to find it. Please help.
practice.php
addtocart.php