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 Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/ 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; Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856362 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 Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856368 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> Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856375 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 Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856435 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" Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856445 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. Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856450 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? Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856461 Share on other sites More sharing options...
richarro1234 Posted June 15, 2009 Author Share Posted June 15, 2009 PM sent Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856472 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? Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856483 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. Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856487 Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 weird...your site kills my Firebug plugin Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856495 Share on other sites More sharing options...
richarro1234 Posted June 15, 2009 Author Share Posted June 15, 2009 hmm, random. Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-856505 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? Link to comment https://forums.phpfreaks.com/topic/162259-help-with-ajax-promlem-please/#findComment-862487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.