1

I have two pages:

  • choose.html
  • create.html

In the choose.html I can choose an entry from a listview. I can click on such entries in the listview and I want to pass the ID of that entry so that I can use the ID on the html page create.html.

ID is a number.

I have done:

When I clicked on an entry, I get the ID:

function postID(id) {
    alert(id);
}

This functions so far.

Then I tried this code with a GET on the create.html:

POST:

function postID(id) {
    $.ajax({
        url: "create.html",
        type: "POST",
        dataType: "text",
        data: id,
        success: function () {
            document.location.href = "create.html";
        },
        error: function (jqXhr) {
            alert("Error");
        }
    });
}

GET:

try {
    $.get("chooseAddress.html", function (id) {
        alert(id);
    });
} 
    catch (e) {
        alert();
}

But nothing happens. Can you help me?

Thanks

urbz
  • 2,663
  • 1
  • 19
  • 29
user3679607
  • 163
  • 2
  • 16
  • 3
    Why can't you simply use `queryString`? Read [How can I get query string values in JavaScript?](http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript) – Satpal Aug 27 '14 at 07:11
  • 1
    use a cookie or add a query to the url which you can then read out – Alex Aug 27 '14 at 07:19

2 Answers2

2

So many work for so simple problem. Use a hidden field or use a Session variable.

FMQB
  • 653
  • 5
  • 12
1

Use create a hidden field and give value as your Id. <form action='create.html'> <input type='hidden' value='id'> </form>