I am currently working on an existing script that uses Ajax, which I have never worked with. I have a variable set in my javascript file that gets its value from the input field on my page. I need to use Ajax to post this on my PHP page, I donβt know where to start,
I'm not sure which code you will need to see, but my javascript / AJAX code, the variable I need to pass is "var credoff"
$(".getPoint").click(function () {
var theid = $(this).attr("id");
var onlyID = theid.split("_");
var onlyID = onlyID[1];
var credoff = parseInt($(this).children('input.credoff:hidden').val());
$.ajax({
url: 'do.php',
type: 'POST',
data: "userID=" + onlyID,
success: function (data) {
if (data != "success1" && data != "success5") {
$("#" + theid).text(data);
} else {
$("#thediv_" + onlyID).fadeOut("slow");
$('#creditsBalance').fadeOut("slow");
newbalance = parseInt($('#creditsBalance').text());
Should it be in this format?
data: "userID=" + onlyID,
"credoff=" + credoff
Liam source
share