www.webdeveloper.com
Results 1 to 5 of 5

Thread: encodeURIcomponent fails the first time (need two clicks to work)

  1. #1
    Join Date
    May 2012
    Posts
    12

    Exclamation encodeURIcomponent fails the first time (need two clicks to work)

    i'm working with a javascript on a drupal website, but the saving function seems to work only as soon as i click 2 times on the "save" button. the code that fires the function is:

    Code:
    var param ="&usuario="+usuario+"&nivel="+nivel+gano+porc_gano+gasto+porc_gasto+tengo+porc_tengo+debo+porc_debo+plazo_debo;
    var s = document.createElement("script");
    s.type = "text/javascript"; s.async = true;
    s.src = direccion_servidor +"setMisDatos?callback=respuestaGuardarMisDatos&param="+encodeURIComponent(param);
    h = document.getElementsByTagName("script")[0];
    h.parentNode.insertBefore(s, h);
    i got the parentNode.insertBefore code from google (the same they use in google analitycs), but still i get error (specifically when he has to do the parentNode.insertBefore part (earlier it was only appendChild, but used to give me the same kind of error. Are the spaces a problem in this sense? Or there might be a better solution? because if i click the second time it enters the setMisDatos function and then works 100%. This is really driving me crazy, can anybody help me?

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    did you try all these without s.async = true;?
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    May 2012
    Posts
    12
    i tried it, but it still doesn't work.. in the netbeans logger, it actually works only if it can enter the setMisDatos function, while when it doesn't work, nothing appears on the logger (making me think that the function is not called). any suggestion?

  4. #4
    Join Date
    May 2012
    Posts
    12
    i even tried changing the encodeURIcomponent with encodeURI, but it still creates problem, what i thinkis that if it doesn't work the first time but then always, i don't believe there is something incorrect with the variables no?

    isn't there a tool to help me check the error better than firefox or chrome web console?

  5. #5
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    the simpliest way to check variables is to alert() them. you can try Opera Dragonfly also
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles