Hey guys I have the following code:
$(document).ready(function () {
$(".atf-submit").click(function () {
atf_name = $(this).parent().parent().find(".user_table");
atf_amount = $(this).parent().parent().find(".user_atf");
runATFinsider();
});
});
function runATFinsider(){
var urlatfinsider = '/pcg/ATF/updateATF_window.php';
var tagatfinsider = $("#insider_dialog");
var promise1a = showUrlInDialogATFinsider(urlatfinsider);
var promise2a = sendUpdateATFwindow();
$.when(promise1a, promise2a).done(function(data1, data2) {
tagatfinsider.html(data1[0]).dialog({
width: '100%',
modal: true
}).dialog('open');
//$('.updaterATF_outerbody').text(data2[0].atfName),
//$('.updaterATF_outerbody').text(data2[0].atfAmount)
//alert(data2[0].atfname);
console.log(data2);
});
}
function showUrlInDialogATFinsider(urlatfinsider)
{
return $.ajax({
url: urlatfinsider
});
}
function sendUpdateATFwindow()
{
return $.ajax({
data: {
'atfName': atf_name.val(),
'atfAmount': atf_amount.val()
}
});
}
Look at the top and lets say the values of atf_name and atf_amount are 'joe and 0' When I do a console.log or alert(data2[0].atfName) it does not exist? It is not defined and when I did the console.log(data2), in place of where the values should be is abunch of HTML of the table and all that the values came from. I don’t know why this is happening and it makes no sense because when I do alert(aft_name.val()) I would get the correct value that was taken?
If you could give me a hand I would appreciate it. Also this code runs when a dialog window is already opened and than this opens another one. I don’t think that should be a problem.
David
Here is the HTML:
<input type='hidden' class='user_table' value='$memusername'/>
<input type='hidden' class='user_atf' value='$memATF'/>
These are inside a table.
Putting this as an answer because I pointed out you don’t need to ajax call to get the values of
atf_nameandatf_amountin the comments to your solution. My suggestion, in order to keep the changes to your code to a minimum, would be to change thesendUpdateATFwindow()to: