RIRedinPA Posted December 3, 2010 Share Posted December 3, 2010 Not sure if that made sense but here is what I am trying to do. I am dynamically building a display of database records in a grid (row, cols). Some of the cells use <select> form objects and I am using AJAX to help build them (the options in the select are stored in a db table). So my code looks like this (the return from the AJAX call is the complete <select><option value=1>...set up: ... //write cell html if (d == 1) { userdata += "<p class=\"datacell date\">" + thisitemarray[1] + "</p>"; } else if (d==2) { //make ajax call to get departments $.ajax({ type: "POST", url: "lib/getDropDowns.php", data: "thistable=departments&selecteditem=" + thisitemarray[1] + "&classnames=userdept userdatainput", success: function(data){ userdata += "<p class=\"datacell department\">" + data + "</p>"; } }); } else if (d == 3) { userdata += "<p class=\"datacell bucket\"><input type=\"text\" value=\"" + thisitemarray[1] + "\" class=\"userbucket userdatainput\" dbid=\"" + dbid + "\"></p>"; } else if (d == 4) { userdata += "<p class=\"datacell pubcode\"><input type=\"text\" value=\"" + thisitemarray[1] + "\" class=\"userpubcode userdatainput\" dbid=\"" + dbid + "\"></p>"; } else if (d == 5) { userdata += "<p class=\"datacell area\"><input type=\"text\" value=\"" + thisitemarray[1] + "\" class=\"userarea userdatainput\" dbid=\"" + dbid + "\"></p>"; } else if (d == 6) { userdata += "<p class=\"datacell hours\"><input type=\"text\" value=\"" + thisitemarray[1] + "\" class=\"userhours userdatainput\" dbid=\"" + dbid + "\"></p>"; } else if (d == 7) { userdata += "<p class=\"datacell description\"><textarea class=\"userdesc\" dbid=\"" + dbid + "\">" + thisitemarray[1] + "</textarea></p>"; }//end d check 2 The problem is that this line of code: success: function(data){ userdata += "<p class=\"datacell department\">" + data + "</p>"; } does not show up on my page. I am assuming because userdata is being seen as a local variable within the function. How can I pull the data being passed from AJAX out into my script so I can use it? Quote Link to comment Share on other sites More sharing options...
Lautarox Posted December 5, 2010 Share Posted December 5, 2010 Have you outputted the userdata var to see what's inside before and after adding the text? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.