I have a JQUERY AJAX post function that will work if there is one function, but if I try and include another function in addition, the second function does not post through to the .PHP script. I am a beginner in JQUERY but have tried every variation, but it will process the first function, but if I add any other functions, will not process those.
<script language="javascript" type="text/javascript">
function toggle[My CSS code](x) {
if ($('#'+x).is(":hidden")) {
$('#'+x).slideDown(400);
} else {
$('#'+x).hide();
}
$('.[My CSS Code]').hide();
}
function add(a,b){
var URL="process.php";
$("#add").text("Processing").show();
$.post(URL,{request:"request",mem1:a,mem2:b,},function(data){
$("#add").html(data).show().fadeOut(12000);
});
}
/////This is where the code stops working and the .php script doesnt work//////////
function accept (x) {
var URL="process.php";
$.post(URL,{ request: "accept", reqID: x, } ,function(data) {
$("#req"+requestID).html('<font color="#000">Accepted</font>').show();
});
}
function deny (x) {
var URL="process.php";
$.post(URL,{ request: "deny", reqID: x, } ,function(data) {
$("#req"+x).html('denied').show();
});
}
</script>
So it will process the add function but not the accept nor deny function via the URL posted in the add. Any ideas would be greatly appreciated. Thanks!
You are only defining the URL in the first function, and it’s var’ed so the other functions don’t have access and have an undefined url