richarro1234 Posted June 15, 2009 Share Posted June 15, 2009 Hello, Im trying to setup a page where people can accept requests without having the page refresh, but i need to send the external page 2 variables from the first page, but for some reason it doesnt work, it works fine if i try to send 1, but not 2. Can someone please help me try to sort this out, here is the code: <script type="text/javascript"> $(function() { $(".addfriend").click(function(){ //Save the link in a variable called element var element = $(this); //Find the id of the link that was clicked var add_id = element.attr("myid"); var addf_id = element.attr("friendsid"); //Built a url to send var info = 'myid=' + add_id, '&friendid=' + addf_id; if(confirm("This will add this person as a friend!")) { $.ajax({ type: "GET", url: "inc/addfriend.php", data: info, success: function(){ } }); $(this).parents(".record").animate({ backgroundColor: "#000000" }, "fast") .animate({ opacity: "hide" }, "normal"); } return false; }); }); </script> I have also tried this line: var info = 'myid=' + add_id, '&friendid=' + addf_id; Like this: var info = 'myid=' + add_id '&friendid=' + addf_id; but it still didnt work. Anyone know how to fix this? Thanks Rich Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 var info = { 'myid' : add_id, 'friendid' : addf_id }; or var info = 'myid=' + add_id + '&friendid=' + addf_id; Quote Link to comment Share on other sites More sharing options...
richarro1234 Posted June 15, 2009 Author Share Posted June 15, 2009 Thanks for the quick response. That seems to run this time, but it doesnt run the "success" bit would that be to the code still not working or the other script not working? Thanks Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 try this: <script type="text/javascript"> $(function() { $(".addfriend").click(function(){ if(confirm("This will add this person as a friend!")){ //Built data to send var data = { 'myid' : $(this).attr('myid'), 'friendid' : $(this).attr('friendsid') }; $.ajax({ type: 'GET', url: 'inc/addfriend.php', data: data, success: function(){ $(this).parents('.record').animate({ backgroundColor: "#000000" }, "fast") .animate({ opacity: "hide" }, "normal"); } }); } return false; }); }); </script> Quote Link to comment Share on other sites More sharing options...
richarro1234 Posted June 15, 2009 Author Share Posted June 15, 2009 Thanks, that worked fine, EDIT: i fixed the PHP bit. it also doesnt fade out after clicking on the link. $.ajax({ type: 'GET', url: 'addfriend.php', data: data, success: function(){ $(this).parents('.record').animate({ backgroundColor: "#000000" }, "fast") .animate({ opacity: "hide" }, "normal"); } }); Thanks Rich Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 Try fading it to opacity 0 instead of "hide" Quote Link to comment Share on other sites More sharing options...
richarro1234 Posted June 15, 2009 Author Share Posted June 15, 2009 still nothing. it works fine on another page, its used to delete comments. it just wont work on this page. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 Is there a page you can link me to with this in action...or can you post the HTML so I can debug it in my browser? Quote Link to comment Share on other sites More sharing options...
richarro1234 Posted June 15, 2009 Author Share Posted June 15, 2009 PM sent Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 Once logged in, where do I look? I assume I don't see any addfriend nodes because I don't have any requests? Quote Link to comment Share on other sites More sharing options...
richarro1234 Posted June 15, 2009 Author Share Posted June 15, 2009 once logged in, refresh the page, i have added a link on the side for it. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 weird...your site kills my Firebug plugin Quote Link to comment Share on other sites More sharing options...
richarro1234 Posted June 15, 2009 Author Share Posted June 15, 2009 hmm, random. Quote Link to comment Share on other sites More sharing options...
kannnan Posted June 24, 2009 Share Posted June 24, 2009 That seems to run this time, but it doesnt run the "success" bit would that be to the code still not working or the other script not working? 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.