Skip to content

Use jQuery params to create URL strings. #24

@jolting

Description

@jolting

jQuery allows you to encode objects into url strings very easily and it's clean.
This will improve readability.

For example in quiz.js the URL generation is ugly.
function linkToQuizFromJSON(url) {
return url.attr("protocol") + "://" + url.attr("host") + url.attr("directory") + "quiz.html" +
"?seed" + seed.toString(16) +
"&jsonString" + url.param("numQuestions") +
extraParams;
}

wouldn't it be better to write
var params = { 'seed' : seed,
'numQuestions' : numQuestions,
...
};
var str = jQuery.param( params );

https://foo.cs.ucsb.edu/seriousjs/index.php/JQuery:URL_Parameters

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions