0

i am try to get latitude and longitude value from ip address
after getting lat and lng value POST in to php file using AJAX and generate new xml file

this is my html file:-

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script type="text/javascript" src="http://j.maxmind.com/app/geoip.js" ></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script>
    function getlg(){
                var lan=geoip_latitude();
                var lng=geoip_longitude();
                var gen = $('#Sex').val();
                var date = $('#date').val();
                    $.ajax({ 
                                type: "POST",
                                url: "http://localhost/SVN/trunk/home/url.php?lat="+lan+"&lng="+lng+'&radius'+$('#radius1').val(),
                                contentType: "text/html",
                                success: function(token)  {

                                },
                                error:function (xhr, ajaxOptions, thrownError){
                                alert(xhr.statusText);
                                alert(thrownError);
                                }    
                        });

                    }
        </script>
    <body>
<div id="region"><h5></h5></div>
Enter Radius: <input type="text" id="radius1"></input>
<input type="button" id="filter"onclick="getlg()" value="Go">
</body>
</head>
</html>                 


this is my php file:-

<?php
function convertNodeValueChars($node) {
    if ($node->hasChildNodes()) {
      foreach ($node->childNodes as $childNode) {
        if ($childNode->nodeType == XML_TEXT_NODE) {
          $childNode->nodeValue = iconv('utf-8', 'ascii//TRANSLIT', $childNode->nodeValue);
        }
        convertNodeValueChars($childNode);         
      }
    }      
  } 
$url='http://services.gisgraphy.com/geoloc/search?lat='.$_GET['lat'].'&lng='.$_GET['lng'].'&radius='.$_GET['radius'];
  $doc = new DOMDocument();
  $doc->load($url);
  $doc->save('General.xml');
?>

in this file i am try to Get lat and long and radius from html ajax function and getting one new xml file with help of url.
but its take so much time if radius is biggest.
i want to try this php code in java script dont like server side scripting.
please help me out with this...
thanks...

1 Answer 1

1

try this:-

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script type="text/javascript" src="http://j.maxmind.com/app/geoip.js" ></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script>
    function myFunction(){
                var lan=geoip_latitude();
                var lng=geoip_longitude();
                var gen = $('#Sex').val();
                var date = $('#date').val();
                        var location = "http://services.gisgraphy.com/geoloc/search?lat="+lan+"&lng="+lng+'&radius'+$('#radius1').val();
                                    document.write('<a href="' + location + '">Link text</a>');
                }
        </script>
    <body>
<div id="region"><h5></h5></div>
<input type="text" id="radius1" onchange="myFunction()"></input>
</body>
</head>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.