Use String Variables in Name Value Pair Argument Lists

Use String Variables in Name Value Pair Argument Lists

I am relatively new to jquery and am trying set up a gmap to display markers on the map via an AJAX call. I can get the map working if I hard code the name value pair arguments as follows:
  1. $('.gmap').gMap({
  2.        zoom: 9, markers: [
  3.             { address: "8539 Spencer Court, Orlando, FL 32817" }, 
  4.             { address: "400 Market Street, Wisconsin Rapids, WI 54494" }
  5.       ]
  6.  });


The AJAX routine returns a string imitating the layout between the markers: [ ] square brackets as follows:

  1. { address: "8539 Spencer Court, Orlando, FL 32817" },
  2. { address: "400 Market Street, Wisconsin Rapids, WI 54494" }


Is there any way to make the string that is returned from my AJAX call the value in the markers name/value pair? Kind of like this (the non-working portion of my code):

  1. $.post(pubRoot+'ajax/get_jq_google_map_markers.php', function(data){
  2.       strData = ""+data;
  3.       $(objMap).gMap({ markers: [ strData ] });
  4. });


Any advice or insight is greatly appreciated!

    • Topic Participants

    • josh