[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
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
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
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
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
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
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] Simplae JQuery/Ajax question - GET variables
On Tue, Jan 19, 2010 at 2:29 PM, parot russ...@parotkefalonia.com wrote: so you could have something like $(button#prevMonth).click(function() { loadMonth(--currentMonth),loadYear(--currentYear); }); Well, to handle year and month you'll want something like: var currentMonth = 1; var currentYear = 2010; function deltaMonth(delta) { currentMonth += delta; while (currentMonth 1) { --currentYear; currentMonth += 12; } while (currentMonth 12) { ++currentYear; currentMonth -= 12; } }
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.
[jQuery] jQuery AJAX Question
I was curious if there was a way to hit the current xhr object in the success callback. I've been tinkering with it, and have been unable to figure out how to do that. The reason I ask is because I am trying to debug an application I've been working on, and sometimes the response XML is not formatted correctly; however, the occurrence seems random, and still triggers the success method, since there are no actual server-side errors. I'm looking to do something like: var data = $.param(myObj); // post data // AJAX to val page $.ajax({ type: POST, url: myval.asp, data: data, dataType: xml, async: true, global: false, cache: false, success: function (objXml) { $(objXml).find(ticket).exists( // see if the ticket is present function () { var ticket = this.attr(number); if (typeof(ticket) === undefined) { errorProcess({ fn: fnName, detail: Ticket is present, but value is null, page: myval.asp, post: data, responseText: xhr.responseText // need tp hit XHR object here }) } // do stuff } ).absent( function () { errorProcess({ fn: fnName, detail: Ticket is not present in response, page: myval.asp, post: data, responseText: xhr.responseText // need to hit the XHR object here }); } ); }, error: functon (xhr) { errorProcess({ fn: fnName, detail: Specifics on what's supposed to happen, page: myval.asp, // page I'm trying to AJAX to post: data, responseText: xhr.responseText }); } }); $(selector).exists() and $(selector).absent() are functions I added. Basically, if the selector is found in the DOM, the callback in exists is executed, if it's not found in the DOM, the callback in absent is executed. I'm needing to hit the XHR object's responseText property inside the success function of the AJAX call, but am not able to do so. Any ideas?
[jQuery] Re: jQuery AJAX Question
I was curious if there was a way to hit the current xhr object in the success callback. I've been tinkering with it, and have been unable to figure out how to do that. No, but you can access the xhr in the 'complete' callback.
[jQuery] jquery ajax question?
Hi y'all, Please look at this code: $('ul#navigation li ul lia').click(function(){ var active = $(this).text(); $('#artcontent p').empty(); $.ajax({ type: 'POST', url: 'homepage/readarticle', data: $(active).serialize(), success: function(databack){ $('#artcontent').append(databack); } }) }); I have a ul li a that are children of parent ul navigation and li. what I am trying to do is to load an article page. This works but it reads the database and loads all the articles in my database instead of the one identified by active. I would like to know what I am doing wrong or is there a better way to go about this?
[jQuery] Re: jquery ajax question?
$(active).serialize() will not do anything to a text element, only input elements. You'd probably want to change your ajax data option to something like: data: { article:active } where article will become your field name in your script. active is your Javascript variable (var active = $(this).text();). If PHP, $_POST['article'] On Oct 7, 11:41 am, rosnovski rosnov...@gmail.com wrote: Hi y'all, Please look at this code: $('ul#navigation li ul lia').click(function(){ var active = $(this).text(); $('#artcontent p').empty(); $.ajax({ type: 'POST', url: 'homepage/readarticle', data: $(active).serialize(), success: function(databack){ $('#artcontent').append(databack); } }) }); I have a ul li a that are children of parent ul navigation and li. what I am trying to do is to load an article page. This works but it reads the database and loads all the articles in my database instead of the one identified by active. I would like to know what I am doing wrong or is there a better way to go about this?
[jQuery] Re: jquery ajax question?
Hey thanks for the reply, the group lives!!! I did that and still nothing. I am using codeigniter and I would like to paste the code incase it sheds more light and maybe a solution? thanks here it is: MODEL- function displayby_name($name) { $this-db-select (articletitle,articlebody,articleauthor); $this-db-from ('articles'); $this-db-where('articletitle',$name); $Q = $this-db- get(); if($Q-num_rows() 0){ $text = $Q-result_array(); } echo $this-db-last_query(); return $text; } CONTROLLER- function readarticle() { $articlename = $this-input-post('active'); $output = $this-articles-displayby_name($articlename); if($output){ $data['article'] = $output; } $this-load-view('loadarticle',$data); } thanks for the help On Oct 7, 10:41 pm, rosnovski rosnov...@gmail.com wrote: Hi y'all, Please look at this code: $('ul#navigation li ul lia').click(function(){ var active = $(this).text(); $('#artcontent p').empty(); $.ajax({ type: 'POST', url: 'homepage/readarticle', data: $(active).serialize(), success: function(databack){ $('#artcontent').append(databack); } }) }); I have a ul li a that are children of parent ul navigation and li. what I am trying to do is to load an article page. This works but it reads the database and loads all the articles in my database instead of the one identified by active. I would like to know what I am doing wrong or is there a better way to go about this?
[jQuery] Re: jquery ajax question?
$this-input-post('active') Is active the right variable? Or did you use article like I put in to my example? This is a jQuery group meant for jQuery questions, so I'm trying to help on the jQuery part, mainly. Try using Firebug for Firefox to debug the AJAX request, and determine whether the expected POST data is being sent or not. That should be your first step. On Oct 7, 1:18 pm, rosnovski rosnov...@gmail.com wrote: Hey thanks for the reply, the group lives!!! I did that and still nothing. I am using codeigniter and I would like to paste the code incase it sheds more light and maybe a solution? thanks here it is: MODEL- function displayby_name($name) { $this-db-select (articletitle,articlebody,articleauthor); $this-db-from ('articles'); $this-db-where('articletitle',$name); $Q = $this-db-get(); if($Q-num_rows() 0){ $text = $Q-result_array(); } echo $this-db-last_query(); return $text; } CONTROLLER- function readarticle() { $articlename = $this-input-post('active'); $output = $this-articles-displayby_name($articlename); if($output){ $data['article'] = $output; } $this-load-view('loadarticle',$data); } thanks for the help On Oct 7, 10:41 pm, rosnovski rosnov...@gmail.com wrote: Hi y'all, Please look at this code: $('ul#navigation li ul lia').click(function(){ var active = $(this).text(); $('#artcontent p').empty(); $.ajax({ type: 'POST', url: 'homepage/readarticle', data: $(active).serialize(), success: function(databack){ $('#artcontent').append(databack); } }) }); I have a ul li a that are children of parent ul navigation and li. what I am trying to do is to load an article page. This works but it reads the database and loads all the articles in my database instead of the one identified by active. I would like to know what I am doing wrong or is there a better way to go about this?
[jQuery] $ajax() question
$.ajax({ type: POST, url: mywebpage.aspx? Arg=+args2, contentType: text, data:{}, dataType: text, success: CompleteInsert, error: onFail }); I dont know why the onFail function is going to be executed when args2 is too big. args2 is a string type can anyone explain this thanks
[jQuery] ajax question
if we want to transfer some variable to another page by ajax, we use data: {a: 1, b: 2} and it will send like xxx.php?a=1b=2 but if a is not a constant variable, such as var $a = x data: {$a: 1} I want it become xxx.php?x=1 var $a = y data: {$a: 1} I want it become xxx.php?y=1 how to do that?
[jQuery] $.ajax question
hi friends, i have a question: i call several times a function in which there is an ajax cal, which, when succesfull, performs a search in the loaded data and return the result/. Will the ajax call (the client/server communication) be performed each time, or will it use the cache and just perform the search part ? Here is my function: function findProjectAnchor(projectName, scape){ var datascapeXml = $.ajax({ type: POST, url: projects/datascapes.xml, dataType: xml, async: true, success: function(xml){ if (projectName != '' scape != '' xml) { var myscape = $(scape[title=' + scape + '], xml); var myItem = $(item:contains(' + projectName + '), myscape).attr('rel'); return myItem; }else { return error; } } }); } THANK YOU Alexandre
[jQuery] $.ajax question
Is there a way to pass the $.ajax object a form id or will i need to convert for form to a string.object and pass the data like that? -- View this message in context: http://www.nabble.com/%24.ajax-question-tf4257664s15494.html#a12116633 Sent from the JQuery mailing list archive at Nabble.com.