This is really bugging me no matter what I''m trying. In javascript, I''m using the ajax.updater, and it (obviously) writes back out to a div. I want to then compare what was echoed out into this div (which came from the php file I listed in ajax.updater) with a string. test should equal "SomeString" because that is what is being echoed out to ''testdiv'', but it doesn''t. Instead, when I try debugging and display test in a div, it shows up as "undefined." Here is example code: function Check(){ new Ajax.Updater(''testdiv'',''randy.php?ajax=1'', {method:''post'',parameters:''somevar=''+somevalue,evalScripts:false}); //wha la, testdiv now displays "SomeString". but wait! crap!..... test = document.getElementById(''testdiv'').value; if (test == "SomeString"){ document.getElementById(''testdiv'').innerHTML=test; return true; } } Thanks for any advice. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
the following code has problem with IE 6 ( select box cannot show): </p><p class="" style="background-color: rgb(255, 255, 153); background-image: none;" title="Click to edit" id="tobeedited">Click me, click me!</p> <script type="text/javascript"> new Ajax.InPlaceCollectionEditor( ''tobeedited'', ''demoajaxreturn.html'', { collection: [''one'',''two'',''three''], ajaxOptions: {method: ''get''} //override so we can use a static for the result }); </script> in control.js 1.8.0 , comment line 838: // this._controls.editor.update(''''); IE6 can show select box. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hello and thanks for the reply. I must be dumb, because I don''t understand how thats works with my issue or how to implement it. I looked at the documentation page and still *confused*. :\ Can you explain more please? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
the div object doesn''t have value property, and it''s better to make a request insted a updater new Ajax.request(''randy.php?ajax=1,{ parameters:{ parameter1:''value1'', parameter2:''value2'', ....... }, onSuccess: function(transport){ var test = $(''testdiv'');//it''s equal to document.getElementById (''testdiv'') if("SomeString" != test.innerHTML) test.update(transport.responseText); } }); for more information: http://www.prototypejs.org/api http://www.prototypejs.org/api/utility/dollar the general options of the Ajax object http://www.prototypejs.org/api/ajax/options And the periodical updater http://www.prototypejs.org/api/ajax/periodicalUpdater Elden. On Wed, Feb 13, 2008 at 2:41 AM, fben125 <fben125-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > This is really bugging me no matter what I''m trying. > In javascript, I''m using the ajax.updater, and it (obviously) writes > back out to a div. I want to then compare what was echoed out into > this div (which came from the php file I listed in ajax.updater) with > a string. > > test should equal "SomeString" because that is what is being echoed > out to ''testdiv'', but it doesn''t. Instead, when I try debugging and > display test in a div, it shows up as "undefined." > > Here is example code: > > function Check(){ > > new Ajax.Updater(''testdiv'',''randy.php?ajax=1'', > {method:''post'',parameters:''somevar=''+somevalue,evalScripts:false}); > //wha la, testdiv now displays "SomeString". but wait! crap!..... > > test = document.getElementById(''testdiv'').value; > > if (test == "SomeString"){ > > document.getElementById(''testdiv'').innerHTML=test; > return true; > } > } > > Thanks for any advice. > > >-- {a human being that was given to fly} --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the new direction, though I''m still having issues. I''ve looked at the links and tried to follow their documentation, but still having issues. Not only can I not get it to work, it also causes all other functions I have, to not work either. This is inside an external js file. Btw, "randy.php" is comparing sendcode (which I want to use via post method) to some session variable, and then echoing "<div id=testdiv>Correct</div>" if true. I had that part working with my old code, but now I don''t think the php file is getting the "id" that I''m trying to send. Here is the function, any ideas?: function codeCheck(){ sendcode = document.getElementById(''code'').value; new Ajax.request(''randy.php'',{ method:''post'',parameters:{''id=''+sendcode}, onSuccess: function(transport){ var test = $(''testdiv''); if("Correct" == test.innerHTML) test.update(transport.responseText); } }); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the new direction, though I wasn''t able to get it to work yet. I am not getting anything back. The php file I have now is just echoing out "<div id=testdiv">Correct</div> if sendcode equals some session variable I have. But it''s not echoing anything back onto the screen, and nothing happens. :\ Here is the function, any ideas?: function codeCheck(){ sendcode = document.getElementById(''code'').value; new Ajax.request(''functions/randy.php'',{ method: ''post'', postBody: escape(''id=''+sendcode), onSuccess: function(t){ var test = $(''testdiv''); if("Correct" == test.innerHTML) test.update(t.responseText); }, onFailure: function(t) { alert(''Error '' + t.status + '' -- '' + t.statusText); }, on404: function(t) { alert(''Error 404: location "'' + t.statusText + ''" was not found.''); } }); } the php file is something like: if(isset($_POST[''id''])){ $id=$_POST[''id'']; if ($id == $compare){ echo "<div id=testdiv>Correct</div>"; die(); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the new direction, though I wasn''t able to get it to work yet. I am not getting anything back. The php file I have now is just echoing out "1" if sendcode equals some session variable I have. But it''s not echoing anything back onto the screen, and nothing happens. :\ And I know the session variable is correct. Here is the function, any ideas?: function codeCheck(){ sendcode = document.getElementById(''code'').value; new Ajax.request(''randy.php'',{ method: ''post'', postBody: escape(''id=''+sendcode), onSuccess: function(t){ var test = $(''testdiv''); if(t.responseText == ''1'') test.innerHTML=''Correct''; }, onFailure: function(t) { alert(''Error '' + t.status + '' -- '' + t.statusText); }, on404: function(t) { alert(''Error 404: location "'' + t.statusText + ''" was not found.''); } }); } php file is something like: if(isset($_POST[''id''])){ $id=$_POST[''id'']; if ($id == $compare){ echo "1"; } else { echo "0"; } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hopefully, the lack of quotes around the ID is just a typo in Mail, right? What do you see back in Firebug when you send the request? If it looks like <div id="testdiv">Correct</div>, then your test might work. I would put the variables in the other order myself, but I don''t know if it matters really: if ($(''testdiv'').innerHTML == "Correct") ... Walter On Feb 13, 2008, at 5:52 PM, fben125 wrote:> > Thanks for the new direction, though I wasn''t able to get it to work > yet. I am not getting anything back. The php file I have now is just > echoing out "<div id=testdiv">Correct</div> if sendcode equals some > session variable I have. But it''s not echoing anything back onto the > screen, and nothing happens. :\ > > Here is the function, any ideas?: > > function codeCheck(){ > > sendcode = document.getElementById(''code'').value; > > new Ajax.request(''functions/randy.php'',{ > method: ''post'', > postBody: escape(''id=''+sendcode), > onSuccess: function(t){ > var test = $(''testdiv''); > if("Correct" == test.innerHTML) > test.update(t.responseText); > }, > onFailure: function(t) { > alert(''Error '' + t.status + '' -- '' + t.statusText); > }, > on404: function(t) { > alert(''Error 404: location "'' + t.statusText + ''" was not > found.''); > } > }); > > } > > > the php file is something like: > > if(isset($_POST[''id''])){ > > $id=$_POST[''id'']; > > if ($id == $compare){ > > echo "<div id=testdiv>Correct</div>"; > > die(); > > } > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
The help here is wonderful! Walter, I must admit, I never even knew of Firebug. It has been a great help. Debugging, I noticed when I switched everything to ''get'' it worked. So going back and looking at what I was doing with post, and doing some reading, I realize I needed to change: postBody: escape(''id=''+sendcode), to postBody: ''id=''+sendcode, and it worked. Thanks to those who helped. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---