Jason28 Posted July 11, 2011 Share Posted July 11, 2011 Hello, I tried searching on the net but couldn't find anything that was similar to what I am doing. I want to use Google +1 so that when the user clicks on it, their ID is sent to a PHP file where I can add code to insert into the DB. Here is the Google code: <g:plusone size="medium" callback="earn" href="http://www.site.com/"></g:plusone> I noticed the callback="" in the g tag acts like an onclick function as I tested it and made it alert something in javascript when I created a javascript function. Could you please provide me with the JQuery needed to pass an ID from that plusone tag to a PHP file please? Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/241704-simple-pass-one-id-value-to-php-using-jquery/ Share on other sites More sharing options...
Adam Posted July 11, 2011 Share Posted July 11, 2011 A callback is a function or piece of code that is called after a specific event or action. In this case it's called after the +1 button is clicked, but it's not triggered by the click event. The Google API will return to call that code after it's done what it does. As for writing it for you, I'm afraid that simply won't happen. We're here to help you if you get stuck trying to do it yourself, not complete your work at your request. We can guide you though.. Creating an AJAX request is extremely easy with jQuery (look into the jQuery.ajax API). As a first step, get that working with a static value. Then concentrate on retrieving the "ID" - although I have no idea where this ID comes from. Is the callback function handed some kind of response data containing it? Never used the Google +1 API before. Quote Link to comment https://forums.phpfreaks.com/topic/241704-simple-pass-one-id-value-to-php-using-jquery/#findComment-1241375 Share on other sites More sharing options...
Jason28 Posted July 11, 2011 Author Share Posted July 11, 2011 I have spent the past two days researching and trying to figure it out but I cannot. I figured this would be an easy two line code for someone who understands JQuery. Sorry but not all of us are rich or living at home with our parents. I learned about 6 programming languages and suddenly JQuery came along and I have to become a doctor in it as well just for it to be replaced again in a couple of years? My brain cannot hold all of that info and my bills are not being forgiving. Quote Link to comment https://forums.phpfreaks.com/topic/241704-simple-pass-one-id-value-to-php-using-jquery/#findComment-1241381 Share on other sites More sharing options...
Adam Posted July 11, 2011 Share Posted July 11, 2011 Did you look at the jQuery.ajax API? It's pretty straight-forward. You can practically copy and paste the code provided, and only have to change the path to your PHP script to get it working. By the way I'm not rich and I don't live with my parents. I don't get what you're getting at there? Many people can pick up jQuery because it's so simple and there's plenty of documentation/tutorials available. If you're not willing to learn it yourself, either pay someone to do it or don't expect to use it. Quote Link to comment https://forums.phpfreaks.com/topic/241704-simple-pass-one-id-value-to-php-using-jquery/#findComment-1241510 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.