E
E
EleGant232014-11-17 08:21:32
JavaScript
EleGant23, 2014-11-17 08:21:32

How to pass a get or post parameter along with a link?

DD! I am writing an application on PhoneGap
Faced such a problem
There are two pages
1. index.html
2. place.html

on the index page data is sucked from the server by JSON type
id - name
on the page they are displayed as How to read on the place.html page using javascript what is equal to - id .... in order to ask the server for JSON data for this id ... or how to correctly transfer data to place.html
<a href="place.html?id=ID">NAME</a><br>


Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
EleGant23, 2014-11-17
@EleGant23

$.get( "test.php", { name: "John", time: "2pm" } );

I found such a thing ... as I understand it, using GET transmits data ...
Mb tell me how to insert this construction here
for(var i=0;i<data.users.length;i++){
                $('#info').append('<div id="place" >' + data.users[i].id + ' - <a href="place.html">' + data.users[i].name + 
                '</a>');
            }

D
Dmitry Entelis, 2014-11-17
@DmitriyEntelis

https://www.google.ru/search?q=javascript+parse+url

V
versoul, 2014-11-17
@versoul

pass the getom parameters to the place.html page
and call this function on it
function parse_get () {
// Process GET requests
var tmp = [];
var tmp2 = [];
var url = location.search;
if(url !== '') {
tmp = (url.substr(1)).split('&');
for(var i=0; i < tmp.length; i++) {
tmp2 = tmp[i].split('=');
_GET[tmp2[0]] = tmp2[1];
}
}
}
after which all get parameters will be stored in _GET

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question