-1

Below is my javascript in nextPage.js. When I click on it, it must pass category_id to the reportlist.html page. Please help me.

var base_url = "http://dev.edfutura.com/nithin/jps/edfuturaMob/";  

$(document).on("pageinit", "#catlist", function() {
    var submitUrl = base_url+"categorylist/get_categorylist"; 
    $.ajax({
        url: submitUrl,
        dataType: 'json',
        type: 'POST',
        success: function(response) {
            var categoryList = $('#category');
            var category;
            for(var i = 0, len = response.length; i < len; i++) {
                category = response[i];
                var a = $('<a>').attr('href', 'reportlist.html').html(category.category_name);
                categoryList.append($('<li>').attr('id', category.category_id).append(a));
            }
        },
        error: function() {
            alert("error");
        }
    }); 

My first page is nextPage.html and my category_names are stored in a list as links through JS.

<body id="category_id">
    <div data-role="page" id="catlist"> 
        <div  id="loading"></div>  
        <div data-role="header" data-position="fixed" data-theme="b">
            <h1>category</h1>
        </div> 
        <div data-role="main" class="ui-content">
            <form id="nextForm" > 
                <ul data-role="listview" data-inset="true" id="category">      
                    <li id="catid"></li>  
                </ul> 
            </form>
        </div>
    </div>                 
</body>
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
roger nm
  • 277
  • 6
  • 19
  • 1
    possible duplicate of [passing form data to another HTML page](http://stackoverflow.com/questions/14693758/passing-form-data-to-another-html-page) – Huey Jul 01 '15 at 07:39

1 Answers1

0

If you want to pass some data when you change the page, you must use request parameters

When you want to pass data in href link, you should use GET request like this:

reportlist.html?category_id=12

Then you can read your data similarly to this https://stackoverflow.com/a/979995/4772988

Community
  • 1
  • 1
suvroc
  • 3,058
  • 1
  • 15
  • 29