jquery - Passing values - all in the same file - not working -



jquery - Passing values - all in the same file - not working -

i need advise. i'm new ajax , jquery. i'm using postgresql 9.1 /postgis 2.0 /openlayers/geoserver , apache.

i managed getting feature's id when clicked on map (openlayers), using javascript.

using ajax m trying pass value php value , perform query. openlayers, jquery, javascript , ajax work fine php never gets value. here code snippets.

//this within openlayers init function function selected_feature(event){ //getting id var sf = event.feature.fid; var sfs = sf.split("."); var sff = sfs[1] //ajax $(document).ready(function() { $.post("map.php", { jas: 'sff'}); }); //the php code snippet, after openlayers $_session['blah'] = $_post['jas']; $blah= $_session['blah']; echo $blah; $queryd=' select pins.p_name pins pins.p_id='.$blah; //fetching fill array $resultd=pg_query($conn, $queryd); $nord=pg_num_rows($resultd); $d=0; while($arrayd=pg_fetch_array($resultd)){ $name[$d]=$arrayd['p_name']; $d++; echo $arrayd['p_name']; echo $arrayd[$d]; }

problem php's echos not working , query not working @ all. know question sounds dublicate believe different because code in same file (named map.php). plus, there web-mapping on background. dont know if 1 of web-mapping programms causing problem.

please advise

thank you.

edit edited ajax part. i've replaced this

jquery.post("map.php", { jas : "sff" }, function(data) { // alert(data); });

...still no luck

edit #2

according this tutorial edited code. have jquery in map.php

jquery.post("testone.php", { jas : sff }, function(data) { alert(data); });

and in testone.php php code

<?php $jas = $_post['jas']; print $jas; ?>

map.php alerts data. but, 1 more thing. how pass info map.php php value, can activate query? tutorials out there alerting info or set them in <div>. want utilize php. like

jquery.post("testone.php", { jas : sff }, function(data) { //put returned info in php var });

i'd move php file , you'll need echo json_encode($name); , handle returned info within callback handler on jquery post.

$.post('new.php',{jas:'sff'},function(data){ //do cool data[0] through lastly index of array });

jquery ajax openlayers

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -