AnsweredAssumed Answered

FM PHP API functionality being interfered with by jQuery

Question asked by duncanbaker on Mar 20, 2016
Latest reply on Mar 21, 2016 by duncanbaker

Hey folks

 

I have a small interaction on a webpage with a FM database. The page loads and it calls back to the database to get some data to display, and it also triggers a script.

 

I'm testing on a new webpage template and while the data is being retrieved fine, the script is not triggering. The piece of code in blue, sitting at the bottom of some Google Maps javascript code, is resulting in an error in Chrome's developer console:

Uncaught TypeError: $ is not a function

 

I think this is because of jQuery being loaded by other functionality of the new webpage and there's a conflict. Now this might be more javascript related than API, but it's preventing the functionality from working. Anyone come across this or know how to fix?

 

Thanks for any tips.

 

function initialize() {

              

    var myLatlng = new google.maps.LatLng(lat, long);

    var mapCanvas = document.getElementById('map-canvas');

    var mapOptions = {

     center: new google.maps.LatLng(lat, long),

       zoom: 6,

       mapTypeId: google.maps.MapTypeId.ROADMAP

    }

    var map = new google.maps.Map(mapCanvas, mapOptions);

   

    var marker = new google.maps.Marker({

     position: myLatlng,

     map: map,

     title: 'Test',

     icon: 'http://google.com/mapfiles/ms/micons/fishing.png',

    animation: google.maps.Animation.DROP

      });

    

    var params = lat + "|" + long + "|" + labelid + "|" + "<?php $ip=$_SERVER['REMOTE_ADDR']; echo "$ip"; ?>" + "|" + "<?php $ip2=$_SERVER['HTTP_X_FORWARDED_FOR']; echo "$ip2"; ?>";

    //alert(params);

    $( "#fm-map" ).load( "fmperformscript.php?params=" + params + "&-findall" );

     }

Outcomes