Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7776053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:46:48+00:00 2026-06-01T17:46:48+00:00

// // // // // // // // Ajax returns from PHP xmlhttp.onreadystatechange=function() {

  • 0
// // // // // // // // Ajax returns from PHP
xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
        var obj = $.parseJSON(xmlhttp.responseText);

        var tLat = getCookie("tLat");
        var tLng = getCookie("tLng");

        var options = {
          zoom: 4,
          center: new google.maps.LatLng(40.7257, -74.0047),
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        // Creating the map  
        var map = new google.maps.Map(document.getElementById('map'), options);

        // Adding a marker to the map
        var marker1 = new google.maps.Marker({
          position: new google.maps.LatLng(tLat, tLng),
          map: map,
          title: 'Click me',
          icon: 'http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png'
        });

        var i = 0;
        for(i=0;i<=10;i++) {
            // Adding a marker to the map
            var marker[] = new google.maps.Marker({
            position: new google.maps.LatLng(obj[i].lat, obj[i].lng),
            map: map,
            title: 'Click me',
            icon: 'http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png'
            });
        }

        $('#map').show();
    }
}
// // // // // // // //

So I have a JSON array and I am trying to load the first ten markers. My JavaScript inside the for loop is a little malformed and I am trying to develop a solution that will add the markers properly from the JSON array. The first marker above the for loop does load properly. Has anyone done this before?

P.S. I also tried this which does not work either. My alert shows floating point values with seven digits after the decimal place.

    // // // // // // // // Ajax returns from PHP
xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
        var obj = $.parseJSON(xmlhttp.responseText);

        var tLat = getCookie("tLat");
        var tLng = getCookie("tLng");

        var options = {
          zoom: 4,
          center: new google.maps.LatLng(40.7257, -74.0047),
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        // Creating the map  
        var map = new google.maps.Map(document.getElementById('map'), options);

        alert(obj[0][1]+','+obj[0][2]);

        //var myLatLng = new google.maps.LatLng(40.7257, -74.0047);
        var myLatLng = new google.maps.LatLng(String(obj[0][1]), String(obj[0][2]));

        var marker = new google.maps.Marker({ position: myLatLng, map: map });

        $('#map').show();
    }
}
// // // // // // // //

P.P.P.S. My alert box for obj is coming with -84.3132324,34.0393598 which looks like the format needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:46:50+00:00Added an answer on June 1, 2026 at 5:46 pm
        // // // // // // // // Ajax returns from PHP
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            var obj = $.parseJSON(xmlhttp.responseText);
    
            var tLat = getCookie("tLat");
            var tLng = getCookie("tLng");
    
            var options = {
              zoom: 4,
              center: new google.maps.LatLng(tLat, tLng),
              mapTypeId: google.maps.MapTypeId.ROADMAP
            };
    
            // Creating the map
            var map = new google.maps.Map(document.getElementById('map'), options);
    
    
    
            var myLatLng = new google.maps.LatLng(parseFloat(obj[0][2]), parseFloat(obj[0][1]));
    
            //var marker = new google.maps.Marker({ position: myLatLng, map: map });
    
            var marker;
    
            for(var i=0;i<obj.length;i++) {
    
                var myLatLng = new google.maps.LatLng(parseFloat(obj[i].lat), parseFloat(obj[i].lng));
    
                var marker = new google.maps.Marker({ position: myLatLng, map: map });
            }
    
            $('#map').show();
        }
    }
    // // // // // // // //
    

    As it turns out this is one of the ways to make things work with APIv3

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to return the ajax success array from one function to another. For
I need to return multiple values from a ColdFusion function in an ajax callback
I'm making a jQuery Ajax POST request to a PHP script that returns an
$(document).ready(function() { function ajaxselectrss(rssurlvar) { var ajaxRequest; // The variable that makes Ajax possible!
I am using an Ajax call to a PHP file to get data from
Im using ajax to call php which gets results from a mysql db. Reason
I've been trying to return special characters from an AJAX request to a PHP
I am trying to display from a MySQL Database using PHP and Ajax but
function ajaxFunction(phpFunction){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera
i'm making an ajax call to a php function... i'm trying to display the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.