Hi John,

There isn't so much a page to show, as I've fixed the
error (and the "fix" was in my php code, not jquery)
and/or you have to be logged in to use the features,
but here's the culprit code that suddenly changed how
it was working. I'm still in novice mode with jquery
so there might be a much easier way of doing this. 

The goal: update the status of a database entry
depending on whatever is selected in a form select
dropdown. Because I needed to keep track of whether
this is a NEW or EXISTING database entry, I appended a
custom ID and name onto each dropdown item. Since I
need to get the info with PHP and selecting the
dropdown does ajax magic, I didn't know another way of
doing this. 

I append EITHER the existing DB entry's ID under the
ID tag, OR the name of the series if the DB entry
doesn't exist yet, under the NAME tag. Thus, either
the ID or NAME tag is empty, while the other is
populated. I then check both in the ajaxed page, and
whichever is populated, I then insert or update an
entry accordingly. 

Here's the jquery ajax calling code:

$("select.status").change(function() {
        var obj = $(this);
        switch (obj.val())
        {
                                                case "0":                       
                var status = "watched";
        break;
                                                case "1":                       
                var status = "watching";
        break;
                                                case "2":
        var status = "dropped";
        break;
                                                case "3":
        var status = "saved";
        break;
    };
    $.ajax(
        {
                                                        type: "POST",           
                        url:
"/users/processanime.php",
        data: ("status=" + obj.val() + "&animeid=" +
obj.attr("name") + "&useranimeid=" + obj.attr("id")),
        success: function(responseText){                                
                        <snip, this stuff doesnt matter>
});

return false;
});

Notice that both the name and ID field are both
passed, even though one is empty.

Now, before the newest version of jquery, in my ajaxed
page (processanime.php) I'd simply do a check for if
(!$var). But after the upgrade, it appears blank
values are passed as undefined (I did an alert
statement). I guess it's not really an "error", just
seems like variables are now passed differently
through the .ajax call if they are blank. An easy
enough fix, just really troublesome due to the many
places on the site I have similar code for; hence if
there's an explanation, I'd love to know what's going
on :)

thanks,
-kim

--- John Resig <[EMAIL PROTECTED]> wrote:

> 
> Kim -
> 
> We haven't seen any errors like this, do you have a
> page up where we
> can see it in action?
> 
> --John
> 
> On 7/8/07, Kim Johnson <[EMAIL PROTECTED]> wrote:
> >
> > Hi folks,
> >
> > I had 100% working jquery code throughout my site,
> but
> > upon updating to the newest version, a TON of
> stuff is
> > no longer working. Specifically, "undefined" is
> > showing up in various variables being passed
> around or
> > gotten via selectors. One thing I've found is that
> > while in the past a blank variable would pass into
> an
> > ajax call as nothing (and in my php code, I could
> then
> > just say if (!$varname) ), now, it's passed as
> > "undefined". Once I put in a bunch of error
> handling
> > it works fine, but this is kind of irritating as I
> > keep discovering similar errors throughout the
> site
> > now.
> >
> > Can someone explain what the fundamental change
> was in
> > the newest jquery that is causing this to happen?
> I'd
> > at least like to understand before I go around
> fixing
> > all the affected areas.
> >
> > thanks,
> > -kim
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Don't get soaked.  Take a quick peak at the
> forecast
> > with the Yahoo! Search weather shortcut.
> >
> http://tools.search.yahoo.com/shortcuts/#loc_weather
> >
> 



       
____________________________________________________________________________________
Get the free Yahoo! toolbar and rest assured with the added security of spyware 
protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php

Reply via email to