Take the 2-minute tour ×

Ah, not used to strings in javascript.

character_id= + id + correct= + correctOrIncorrect

That is what I need to make into a string. If you cannot guess the variables in the string they are id, and correctOrIncorrec.

How can I make this into a javascript string?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

It's a ajax call through jQuery

Then give jQuery a JS object of the parameters:

    url: '/something.url',
    data: {character_id: id, correct: correctOrIncorrect}

If you try to create a serialised data string of your own, you will have to worry about getting the URL-encoding right. So let jQuery work it out instead.

share|improve this answer
This looks like it. Will give it a try on the plane ride to CA –  Dark Passenger Dec 23 '10 at 12:47


'character_id=' + id + 'correct=' + correctOrIncorrect
share|improve this answer
Parameters: {"character_id"=>"2correct=true"} that is what I'm getting –  Dark Passenger Dec 23 '10 at 6:13
can you explain a little more –  Nik Dec 23 '10 at 6:19
It's a ajax call through jQuery :) –  Dark Passenger Dec 23 '10 at 6:20
so, it is basically json that you are getting. Correct me if i am wrong. so are you getting {"character_id"=>"2correct=true"} or {"character_id"=>"2","correct"="true"} because as per your question i guess you might be getting second value. please clarify. –  Nik Dec 23 '10 at 6:23
it is json. not sure what secon is. but I'm just sending object –  Dark Passenger Dec 23 '10 at 6:24

Your Answer


