any of the other web geeks grok jQuery?

Non-Disc Golf Stuff

Moderators: Timko, Solty, Frank Delicious, Blake_T, Fritz, Booter

any of the other web geeks grok jQuery?

Postby SkaBob » Wed Jan 27, 2010 2:13 pm

Can't access google groups or the jquery mailing list through the firewall/proxy nonsense at work...My employer makes China look free and open in terms of website access!

Why won't this set the value of a hidden input?

Code: Select all
HTML:
<input type="hidden" name="foo" id="foo">

jQuery JS:
$("#foo").val('bar');
I threw Wizards before they were cool.
SkaBob
Disc Whore
 
Posts: 3493
Joined: Fri Mar 16, 2007 9:51 am
Location: Detroit
Favorite Disc: Comet

Re: any of the other web geeks grok jQuery?

Postby chiggins » Wed Jan 27, 2010 2:28 pm

It should, where are you making the js call from? (I'm thinking maybe it needs to be in a $(document).ready() function in order to wait until the input's been added to the DOM?)
chiggins
2009 DGR Donator
User avatar
 
Posts: 751
Joined: Mon Apr 27, 2009 8:51 am

Re: any of the other web geeks grok jQuery?

Postby SkaBob » Wed Jan 27, 2010 2:31 pm

It's in a function run by an onClick event... the onClick fires off an AJAX call, and the success routine on that pulls values from the xml it gets fed back and assigns them to a bunch of places on the page.

For some reason the hidden input isn't getting it's value, though...I've also tried

Code: Select all
$(input[name=foo]).val('bar');


without any success...
I threw Wizards before they were cool.
SkaBob
Disc Whore
 
Posts: 3493
Joined: Fri Mar 16, 2007 9:51 am
Location: Detroit
Favorite Disc: Comet

Re: any of the other web geeks grok jQuery?

Postby Frank Delicious » Wed Jan 27, 2010 2:33 pm

Are you sure there is a value for it to pull?
Frank Delicious
The Crime Prince of Clown
User avatar
 
Posts: 12364
Joined: Thu Mar 23, 2006 3:43 pm
Location: Drowning in a cold river
Favorite Disc: Wraith

Re: any of the other web geeks grok jQuery?

Postby chiggins » Wed Jan 27, 2010 2:34 pm

1. are you running Firebug in Firefox?

2. if you are, when the page loads, if you go to the console and put:

$("#foo").val('bar');

What's it return?
chiggins
2009 DGR Donator
User avatar
 
Posts: 751
Joined: Mon Apr 27, 2009 8:51 am

Re: any of the other web geeks grok jQuery?

Postby SkaBob » Wed Jan 27, 2010 2:35 pm

Frank Delicious wrote:Are you sure there is a value for it to pull?


I thought of that, and tried it just putting a string in rather than the variable I pull from the xml, and it still says "undefined" when I alert the value of the hidden input.
I threw Wizards before they were cool.
SkaBob
Disc Whore
 
Posts: 3493
Joined: Fri Mar 16, 2007 9:51 am
Location: Detroit
Favorite Disc: Comet

Re: any of the other web geeks grok jQuery?

Postby SkaBob » Wed Jan 27, 2010 2:37 pm

chiggins wrote:1. are you running Firebug in Firefox?

2. if you are, when the page loads, if you go to the console and put:

$("#foo").val('bar');

What's it return?


>>> $('#betaClientFormKey').val('foo');
[]
I threw Wizards before they were cool.
SkaBob
Disc Whore
 
Posts: 3493
Joined: Fri Mar 16, 2007 9:51 am
Location: Detroit
Favorite Disc: Comet

Re: any of the other web geeks grok jQuery?

Postby chiggins » Wed Jan 27, 2010 2:45 pm

How about just this part?

SkaBob wrote:
Code: Select all
>>> $('#betaClientFormKey')


I just wrote a small test page, put it in the same dir with jquery.js and it works on the first load (on a reload, firefox is repopulating it with the last known value, so you have to shift-reload). This works. I suspect it just can't find the node?

Code: Select all
<html>
  <head>
    <script src="jquery.js"></script>
    <script>
      $(document).ready(function(){
        alert("value of #foo before setting: " + $("#foo").val());
        $("#foo").val("bar");
        alert("value of #foo after setting: " + $("#foo").val());
      });
    </script>
  </head>
  <body>
    <form>
      <input type="hidden" name="foo" id="foo" value="not bar" />
    </form>
  </body>
</html>
chiggins
2009 DGR Donator
User avatar
 
Posts: 751
Joined: Mon Apr 27, 2009 8:51 am

Re: any of the other web geeks grok jQuery?

Postby SkaBob » Wed Jan 27, 2010 2:54 pm

I'm pretty sure it can find the node...when I make the input a text input rather than hidden (same name/id, etc.), it works.

it's always something bizarre with the shit I have to work on... :evil:
I threw Wizards before they were cool.
SkaBob
Disc Whore
 
Posts: 3493
Joined: Fri Mar 16, 2007 9:51 am
Location: Detroit
Favorite Disc: Comet

Re: any of the other web geeks grok jQuery?

Postby chiggins » Wed Jan 27, 2010 3:11 pm

Okay, when I check my test page from the command line, it returns:

Code: Select all
>>> $("#foo")
[input#foo bar]


...whereas when I check something I know isn't there:

Code: Select all
>>> $("#food")
[]


...empty array. There's no "#food" node, but there is a '#foo' node, that's why I ask. If you're putting $('#betaClientFormKey') on the command line in Firebug, and it's coming back with an empty array, it can't find the node.
chiggins
2009 DGR Donator
User avatar
 
Posts: 751
Joined: Mon Apr 27, 2009 8:51 am

Re: any of the other web geeks grok jQuery?

Postby SkaBob » Wed Jan 27, 2010 3:17 pm

Indeed...but for some reason it can see it when it's a text input. It just can't see it when it's a hidden field.

It'll bug me, and I'll test it at home with some of my own code tonight, and it'll work like it should, I know...

For the purposes of my project at work, I ran completely out of giveashit and just kept it as a text input. It doesn't affect the flow of the thing, and I just can't be bothered to beat my head against the wall with it any more when I have to demo this with the user tomorrow morning. Too many other bits on this turd to polish before then. :lol:

Actually it's not a turd...it's some really nice work, it's just fucking obnoxious and has been a pain to deal with at every corner. One of those projects where the RFS says "We need a thing to do stuff and make our job easier", and you don't find out until after deadlines have been set that making the thing to do that is about 900 more hours than the deadlines allow for...

But far be it from my employer to listen to reason. They had a deadline in mind that's far more important to them than what the project does.
I threw Wizards before they were cool.
SkaBob
Disc Whore
 
Posts: 3493
Joined: Fri Mar 16, 2007 9:51 am
Location: Detroit
Favorite Disc: Comet

Re: any of the other web geeks grok jQuery?

Postby Jesse B 707 » Wed Jan 27, 2010 8:15 pm

just when i think i know something about computers :shock:
http://ufosdg.org/
XXX,PD2,BOSS,KATANA,PD,ROC,VP,RATTLER,MAGNET
Jesse B 707
Rocstar
User avatar
 
Posts: 8225
Joined: Sun Dec 23, 2007 9:29 am
Location: *NorCal*
Favorite Disc: ROC

Re: any of the other web geeks grok jQuery?

Postby SkaBob » Fri Jan 29, 2010 1:41 pm

Hey chiggins...I got another funky one for ya...it's drivin' me up the wall and ruining my friday

I've got jQuery's AJAX form plugin handling a form submission, and when it comes back I'm reading a value from the XML I have the submission script return. Everything was working great yesterday. I've made changes to the code, but not to THIS code...

Code: Select all
  $("#vendorInterface").submit(function() {
   $(this).ajaxSubmit({
    beforeSubmit: validateForm,
    cache: false,
    success: function(xml) {
     var fileMode = 'new' // <-- this is populated in perl because I got fed up with jQuery ignoring all of my hidden fields
     if (fileMode == 'new') {
      var newRequestId = $("request_id", xml).text();
      var editURL = 'VendorInterfaceTracking.cgi?mode=edit&requestNum=' + newRequestId;
      window.location = editURL;
     }
    },
    error: function(xml) {
     alert('There was a problem saving this request.  Please file a support ticket.');
    }
   });
   return false;
  });


That's the submit handling code.

Here's what's returning from the filer:
Code: Select all
Content-Type: text/xml
Expires: Mon, 26 Jul 1997 05: 00: 00 GMT

<filer_response>
 <request_id>88</request_id>
</filer_response>


So, it should reload the page (the editURL is the same script, in "edit" mode, rather than "new request" mode), and load request number 88 for editing.

It does, in Firefox. It doesn't in Internet Exploder - which is, of course, the browser the company uses and thus the browser it has to work in before this can be rolled out to production.

In Firefox, it reloads with the correct request number. In IE it reloads, but the request number is blank, so the url ends up 'VendorInterfaceTracking.cgi?mode=edit&requestNum=', and it doesn't actually load any request... If I put in an alert to show what value it's reading from the xml response, it pops up a blank value, not undefined....

Any idea why that works in FF but not IE? Am I violating some sensibility IE has about something? Like I said, I changed the code earlier today, but not THIS code. I commented out the code I changed and it still fails...so I'm doubly confuzzled....

HALP!
I threw Wizards before they were cool.
SkaBob
Disc Whore
 
Posts: 3493
Joined: Fri Mar 16, 2007 9:51 am
Location: Detroit
Favorite Disc: Comet

Re: any of the other web geeks grok jQuery?

Postby JohnnyB » Sat Jan 30, 2010 12:48 am

Thanks for reminding me to read stranger again.
"A hedgehog was also killed"
JohnnyB
Steward Turkeylink: This ranks means I can't read or follow basic directions
User avatar
 
Posts: 435
Joined: Sat Aug 09, 2008 10:44 pm
Location: Utah
Favorite Disc: Star tee-rex

Re: any of the other web geeks grok jQuery?

Postby chiggins » Sat Jan 30, 2010 5:15 am

SkaBob wrote:Hey chiggins...I got another funky one for ya...it's drivin' me up the wall and ruining my friday


Was out sick the last couple days, sorry about that. I'm not a master of IE debugging by any means, and so far I've been pretty lucky about not having to be. The only thing I could recommend is:

1.) have the server side dump the request when it comes in, along with a few debug statements where that value gets set, to your logs, and
2.) have that xml dump itself with a 'alert(xml.to_string)'

Then do the request from both browsers and see what the difference is. Like I said, I'm not an expert on IE quirks, but jQuery's typically pretty good at handling cross-browser issues, which makes me wonder what IE's passing through on the request. Or maybe I'm wrong. (If/when you figure it out, lemme know.)
chiggins
2009 DGR Donator
User avatar
 
Posts: 751
Joined: Mon Apr 27, 2009 8:51 am

Next

Return to Off-Topic, Miscellaneous, etc.

Who is online

Users browsing this forum: No registered users and 2 guests