Grow your CSS skills. Land your dream job.

jQuery.load() + WordPress = fail

  • # March 9, 2012 at 6:31 pm

    This of course works perfectly fine in practice when it is stand alone and has nothing to do with wordpress…but when ported over there are obviously complications. How can i simply get my dynamic dropdowns to change when using wordpress?!

    PLEASE help!


    jQuery.noConflict();
    jQuery(document).ready(function($) {
    $("#state").change(function() {
    $("#county").load("http://wwwvibrantusa.zippykid.it/wp-content/themes/medica/" + $(this).val() + ".php");
    });
    });​

    Here is the fiddle proving it SHOULD work…
    http://jsfiddle.net/M5XkX/

    I am guessing there is some kind of conflict, perhaps someone can help?!

    # March 9, 2012 at 6:53 pm

    Is that the entirety of the code? If so, you haven’t closed everything properly. There are two open curly brackets but only one closed.

    # March 9, 2012 at 7:00 pm

    Oh no. It isn’t…that is just the single function…

    # March 9, 2012 at 7:01 pm

    TheDoc is right, the code in jsFiddle works because it’s not the same as what you have in the post

    # March 9, 2012 at 7:02 pm

    I have the same code in the theme as i do in the fiddle…just pasted it wrong above is all… I fixed the code above.

    Rob
    # March 9, 2012 at 7:10 pm

    Stupid question but did you enqueue jQuery or did you just add it to the header?

    # March 9, 2012 at 7:14 pm

    Not a stupid question… Enqueued…. and yes it was placed before wp_head.

    # March 9, 2012 at 7:16 pm

    Is it possible to link us to your site or is it running locally?

    # March 9, 2012 at 7:19 pm

    wwwvibrantusa.zippykid.it

    Thanks again guys.

    # March 9, 2012 at 7:23 pm

    Very clean looking professional site, I like it
    Where is this drop down? *EDIT found it

    Which script is this function in? there’s quite a few loaded

    # March 9, 2012 at 7:32 pm

    http://wwwvibrantusa.zippykid.it/wp-content/themes/medica/js/general.js

    the function is right at the top.

    # March 10, 2012 at 4:45 am

    Hi sorry for the delay, I fell asleep :P

    There’s an error in general.js causing it to break

    change

    if ($(this).scrollTop() != 0) {

    to this

    if ($(this).scrollTop() !== 0) {

    I think there might be more though :S

    # March 10, 2012 at 11:24 am

    ya, it would appear to be a little more complicated unfortunately :( thanks for the response!

    # March 10, 2012 at 12:05 pm

    For the moment try removing it from general.js and inline it on the page to rule out external errors

    Rob
    # March 10, 2012 at 12:50 pm

    Chrome is reporting an illegal token at the end of that file – it looks like this to me – right after the closing semicolon:

    http://grab.by/ciCk

    maybe you have some kinda extra invisible char you need to delete?

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".