Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This question already has an answer here:

Query string :

Pages/Service.aspx?id=4&comment=1

I am new to jquery ,Kindly help me out with a simple solution to get the Id and COMMENT in "var id & var comment" using jQUERY in asp.net C#

share|improve this question

marked as duplicate by karthikr, Juhana, Mark Schultheiss, Salman A, dfsq May 3 '13 at 20:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
What does jQuery have to do with parsing strings? –  Salman A May 3 '13 at 19:58

1 Answer 1

Use following code

<script>
    function getQuery(key){
        var temp = location.search.match(new RegExp(key + "=(.*?)($|\&)", "i"));
        if(!temp) return.
        return temp[1];
    }

    var id = getQuery('id');
    var comment = getQuery('comment');

</script>
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.