[jQuery] Simplae JQuery/Ajax question - GET variables
I am very (very) used to PHP but just trying to grips with JQuery/Ajax and this is a very simple problem that I cannot find an easy - understandable answer to especially one that works - strange I know. My experience is that all answers to this question - on another site - are too complex and totally miss the point. Take a standard HTML link Get this page now add a get variable ?trythis=a-changing-value Get this page I want to pass ?trythis=a-changing-value via JQuery/Ajax to another page, perform a query based on the actual value of 'trythis' ( but for this example I am only using echo $_GET[] as I can work out the PHP query with ease ONCE i can get the trythis variable to the page) and then display those results without a page refresh on the original page. e.g. Page one in the head: $(document).ready(function() { $(#idoflink).click(function() { somewhere I need to declare the variable trythis and use it in JQuery/Ajax- WHERE and HOW and no a fixed hard coded reply will not help, the variable trythis will have changing values $(#display_results_here).load(tryit.php); }); }); In the body ?trythis=a-changing-value Get this page div id=display_results_here/div Then on the page tryit.php a simple echo $_GET['trythis']; What I cannot do and I do not seem to get a sensible, easy to follow and understandable answer from knowledgeable JQuery people is find out how to pass the valiable trythis to the page tryit.php and then return the result, in this case a simple php echo. -- View this message in context: http://old.nabble.com/Simplae-JQuery-Ajax-question---GET-variables-tp27229104s27240p27229104.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
Re: [jQuery] Simplae JQuery/Ajax question - GET variables
Thnks Nathan, Very near, but it is more basic than that - how do I get the variable ?trythis=changable value into var trythis=; Sounds silly and quiet simpel, but can I get a plain english answer - no Thanks for your reply Nathan Klatt-2 wrote: On Tue, Jan 19, 2010 at 11:06 AM, parot russ...@parotkefalonia.com wrote: What I cannot do and I do not seem to get a sensible, easy to follow and understandable answer from knowledgeable JQuery people is find out how to pass the valiable trythis to the page tryit.php and then return the result, in this case a simple php echo. I must misunderstand you... var trythis = 57; $.get(tryit.php, { trythis: trythis }, function(data) { $(#resultsGoHere).html(data); }); Nathan -- View this message in context: http://old.nabble.com/Simplae-JQuery-Ajax-question---GET-variables-tp27229104s27240p27229508.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
Re: [jQuery] Simplae JQuery/Ajax question - GET variables
Hi Nathan http://www.websequencediagrams.com - now I'm really confused I think I understand it but but let me explain I want to scroll back and forward through the months on a calendar without refreshing the page. I have the php calendar, but I don't want any page refresh which I can do with PHP and just send the GET to the page. so ideally what I need is 2 links back and forward with the month variable i.e. 1-12 (Jan - Dec) passed to JQury/Ajax. I have been looking at a number of scripts, but all to far complex (i.e. do more than I need) just I cant fathom out how to pass Back (Jan go to Dec) or Forward (Jan go to Feb) and so on. just need 1 month at a time, nothing fancy etc. Nathan Klatt-2 wrote: On Tue, Jan 19, 2010 at 11:32 AM, parot russ...@parotkefalonia.com wrote: Very near, but it is more basic than that - how do I get the variable ?trythis=changable value into var trythis=; Maybe a sequence diagram would be helpful. Here's what I hear you asking: http://www.websequencediagrams.com/?lz=bm90ZSBsZWZ0IG9mIHdlYnBhZ2U6IG1lIGZpcnN0IQpKYXZhc2NyaXB0LT50cnlpdC5waHA6IHRyeXRoaXMgPSA1NwoAPwVyaWdoAEAFABsLU2ltcGxlIGVjaG8gb2YgdmFyaWFibGUANggKAEgJLS0-AF8KOiA1NwBrDQCBDgkACQ8AexUic29tZXRoaW5nIGVsc2UiAExSAFERAIEXFQB3EQs=default Could you modify that to better explain what you mean, maybe? Nathan -- View this message in context: http://old.nabble.com/Simplae-JQuery-Ajax-question---GET-variables-tp27229104s27240p27231466.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
Re: [jQuery] Simplae JQuery/Ajax question - GET variables
Nathan, what can I say, perfect. Thanks a lot. Think I understand it, Do years automatically increment / decrease with +newYear -newYear like months so you could have something like $(button#prevMonth).click(function() { loadMonth(--currentMonth),loadYear(--currentYear); }); Nathan Klatt-2 wrote: On Tue, Jan 19, 2010 at 1:45 PM, parot russ...@parotkefalonia.com wrote: I want to scroll back and forward through the months on a calendar without refreshing the page. I have the php calendar, but I don't want any page refresh which I can do with PHP and just send the GET to the page. so ideally what I need is 2 links back and forward with the month variable i.e. 1-12 (Jan - Dec) passed to JQury/Ajax. I have been looking at a number of scripts, but all to far complex (i.e. do more than I need) just I cant fathom out how to pass Back (Jan go to Dec) or Forward (Jan go to Feb) and so on. just need 1 month at a time, nothing fancy etc. How's about something like this? button id=prevMonthPrevious month/button div id=calendar/div button id=nextMonthNext month/button script type=text/javascript var currentMonth = 1; function loadMonth(newMonth) { $(#calendar).load(getCalendar.php?m=+newMonth); } $().ready(function() { loadMonth(currentMonth); $(button#prevMonth).click(function() { loadMonth(--currentMonth); }); $(button#nextMonth).click(function() { loadMonth(++currentMonth); }); }); /script -- View this message in context: http://old.nabble.com/Simplae-JQuery-Ajax-question---GET-variables-tp27229104s27240p27232199.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
Re: [jQuery] need help with simple jQuery problem
Hi Rory Like you a jQuery novice, but think I can help. Though I agree there seems to be a lot of code in here/there that is not needed - plus would not validate against W3C standards e.g. take out the p after the /h6 and replace your / 's with strong / strong. Anyhow here goes - and I have no dobut it can be simplified more $(document).ready(function(){ $('a.hide').hide(); return false; }); This is a standard a href = link with an id of hide and makes sure it is hidden when the page opens Create another link a href = with an id of toggle (OK you can name them what you want) Then in the head try something like $(document).ready(function(){ $('a.toggle').click(function() { $('.demo').toggle(400); $('a.toggle').hide(slow); $('a.hide').show(slow); return false; }); }); $(document).ready(function(){ $('a.hide').click(function() { $('.demo').hide(slow); $('a.toggle').show(slow); $('a.hide').hide(slow); return false; }); }); OK, this assumes that the links - hide and toggle are out site your CSS demo class but you can move them insider the class and hide/show only based on the links. e.g. $(document).ready(function(){ $('a.toggle').click(function() { $('.demo').show(slow); return false; }); }); $(document).ready(function(){ $('a.hide').click(function() { $('.demo').hide(slow); return false; }); }); Rory Bernstein wrote: Hello, I am a total jQuery novice, and I tried to use jQuery for a project but I'm having trouble. http://www.rorybernstein.com/stage/index2.html When you click the blue go ahead link, it expands the hidden div, revealing content. I want the effect to be a slide effect, as on this sample page: http://adipalaz.awardspace.com/experiments/jquery/expand.html From these various examples, I want the slideToggle effect - slideToggle (slow), as shown in section 2 of the above link. I cannot figure out what is wrong; my toggle link does work (it expands the hidden div), but I do not know how to get it to slide at the speed shown in the sample. Any help would be appreciated. Thanks, Rory -- View this message in context: http://old.nabble.com/need-help-with-simple-jQuery-problem-tp27228125s27240p27229401.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
Re: [jQuery] Simplae JQuery/Ajax question - GET variables
Natahn, Very very nearly there - just ummm not sure where to put the Year code. Other than that works perfectly in the calander I want which has a show / hide function for a form with an ajax reply - I got tha bit working perfectly, it was just using JQuery to prefect a page refresh on the month change. That now happensd thanks, just - sorry to be a pain, where do I put thae year function. Thanks a real lot. parot wrote: Nathan, what can I say, perfect. Thanks a lot. Think I understand it, Do years automatically increment / decrease with +newYear -newYear like months so you could have something like $(button#prevMonth).click(function() { loadMonth(--currentMonth),loadYear(--currentYear); }); Nathan Klatt-2 wrote: On Tue, Jan 19, 2010 at 1:45 PM, parot russ...@parotkefalonia.com wrote: I want to scroll back and forward through the months on a calendar without refreshing the page. I have the php calendar, but I don't want any page refresh which I can do with PHP and just send the GET to the page. so ideally what I need is 2 links back and forward with the month variable i.e. 1-12 (Jan - Dec) passed to JQury/Ajax. I have been looking at a number of scripts, but all to far complex (i.e. do more than I need) just I cant fathom out how to pass Back (Jan go to Dec) or Forward (Jan go to Feb) and so on. just need 1 month at a time, nothing fancy etc. How's about something like this? button id=prevMonthPrevious month/button div id=calendar/div button id=nextMonthNext month/button script type=text/javascript var currentMonth = 1; function loadMonth(newMonth) { $(#calendar).load(getCalendar.php?m=+newMonth); } $().ready(function() { loadMonth(currentMonth); $(button#prevMonth).click(function() { loadMonth(--currentMonth); }); $(button#nextMonth).click(function() { loadMonth(++currentMonth); }); }); /script -- View this message in context: http://old.nabble.com/Simplae-JQuery-Ajax-question---GET-variables-tp27229104s27240p27232554.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
Re: [jQuery] Simplae JQuery/Ajax question - GET variables
Hi Nathan Thanks a lot for everything, managed to sort the years out OK not in the java but in the PHP page - I'm just an old fashioned PHP type of guy really. Thanks alot for everything parot wrote: Natahn, Very very nearly there - just ummm not sure where to put the Year code. Other than that works perfectly in the calander I want which has a show / hide function for a form with an ajax reply - I got tha bit working perfectly, it was just using JQuery to prefect a page refresh on the month change. That now happensd thanks, just - sorry to be a pain, where do I put thae year function. Thanks a real lot. parot wrote: Nathan, what can I say, perfect. Thanks a lot. Think I understand it, Do years automatically increment / decrease with +newYear -newYear like months so you could have something like $(button#prevMonth).click(function() { loadMonth(--currentMonth),loadYear(--currentYear); }); Nathan Klatt-2 wrote: On Tue, Jan 19, 2010 at 1:45 PM, parot russ...@parotkefalonia.com wrote: I want to scroll back and forward through the months on a calendar without refreshing the page. I have the php calendar, but I don't want any page refresh which I can do with PHP and just send the GET to the page. so ideally what I need is 2 links back and forward with the month variable i.e. 1-12 (Jan - Dec) passed to JQury/Ajax. I have been looking at a number of scripts, but all to far complex (i.e. do more than I need) just I cant fathom out how to pass Back (Jan go to Dec) or Forward (Jan go to Feb) and so on. just need 1 month at a time, nothing fancy etc. How's about something like this? button id=prevMonthPrevious month/button div id=calendar/div button id=nextMonthNext month/button script type=text/javascript var currentMonth = 1; function loadMonth(newMonth) { $(#calendar).load(getCalendar.php?m=+newMonth); } $().ready(function() { loadMonth(currentMonth); $(button#prevMonth).click(function() { loadMonth(--currentMonth); }); $(button#nextMonth).click(function() { loadMonth(++currentMonth); }); }); /script -- View this message in context: http://old.nabble.com/Simplae-JQuery-Ajax-question---GET-variables-tp27229104s27240p27233076.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.