Hello, If I use the first code it deletes the rows properly but when I
try and put the remove function after success it doesn't work. Does
anyone know why it doesn't remove the row. Sorry I'm really new to programming.
First:
function acceptFriendRequest(a,b) {
var row = $('#user'+b).index();
$("#request tr:eq("+row+")").remove();
var token = $("#token").val();
$.ajax({
type:"post",
url:"?.php",
data: { user: a, friend: b, token: token },
error:function(){
console.log(arguments)},
success:function(data){
$("#token").attr('value', data);
}
})
}
Second:
function acceptFriendRequest(a,b) {
var row = $('#user'+b).index();
var token = $("#token").val();
$.ajax({
type:"post",
url:"?.php",
data: { user: a, friend: b, token: token },
error:function(){
console.log(arguments)},
success:function(data){
$("#request tr:eq("+row+")").remove();
$("#token").attr('value', data);
}
})
Hello everyone, I'm new with JQuery and I'm stuck parsing my JSON response back from PHP using $post ajax. The dataType is json and my response header is application/json but not matter what i try i can't get it to work, it won't even alert anything when I try everything I can research. I can echo out the options as html and put them in a select but when I try and send multiple data in any other format I can't get it to parse...
My JSON response which I'm receiving is:
Product{"data":[{"option":"Product1"},{"option":"Product2"},{"option":"Product3"}],"token":"9eb19fcc48786dba13c293279ec5b0ac"
}.
What I need to do is put the option:'s into a select and the token into three different hidden inputs with the class name token.
I've been rewriting my js and the layout of my JSON a million times for the last week and I'm about to give up on ajax if I can't parse multiple data and get my CSRF tokens to update.
I have a feeling it's in my layout of my JSON response but I've changed that a bunch too, so I have no idea... Can you guys/gals please show me how to parse responses and replace elements?