Take the 2-minute tour ×

I thought this was going to be rather simple but I'm a bit rusty.

I call this javascript/jquery code:

$.get("plugin.php", {up_vote:surl},
    document.getElementById('numvotes').innerHTML = data;

And when it returns I get the value, which is some number that is returned as a string, then right after the number a long text about redirecting is displayed. How do I get rid of that? I just want the value. Here is what is returned: 8 (if you are not redirected after 10 seconds, please click here)

What is causing this to redirect? Or, how do I just get rid of that '(if you are ....) text?

share|improve this question
data = data.match(/^\d{1,}/); document.getElementById('numvotes').innerHTML = data; This combination worked! For some reason, the regex did not work with jquery, and the jquery $('#numvotes")... would just display the text for a few seconds then disappear. –  kirtcathey Jun 1 '12 at 12:04
add comment

2 Answers

You could try using


if the result is always going to be in the same format that you gave in your question.

share|improve this answer
did that. same thing and then it suddenly disappears after a few seconds, making it two problems to fix. –  kirtcathey Jun 1 '12 at 11:45
Now that looks like bubble gum and paper mache... my kinda fix right now. Thank you. UPDATE - Didn't work. The regex does something, so that means that giorgio is probably correct, it's a data type issue. –  kirtcathey Jun 1 '12 at 11:52
add comment

It is actually your plugin.php sending the redirect text (and probably some other html too). Try to browse directly to plugin.php?up_vote=surl and you'll see what happens.

Furthermore, if you are using jquery anyway, why not change document.getElementById() to:

share|improve this answer
thank you. As mentioned below, the jquery representation disappears after a few seconds (strangely) and also displays all the same stuff. Thanks for the tip on opening up plugin.php directly. Shoulda thoughta that! –  kirtcathey Jun 1 '12 at 11:48
add comment

Your Answer


