javascript - Wordpress JS Conflict: Inserting JS via custom post disables all JS on the page -
i using savant themeto build website, use following js code on pages (using custom fields, use field name "example" assign js in value) list of properties calling api , receiving json data.
js code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript" language="javascript"></script> <!--<script type="text/javascript" src="http://www.bedstax.com/realtordata/featuredcommunities.php?state=fl&area=bonita springs%20/%20estero"></script> //--> <script type="text/javascript"> var state = 'fl'; var area = 'bonita springs / estero'; var idx = '583'; var agent = '1212'; var domain = 'xxx'; function setcommunity(community,communityname) { var cookieset = window.state + "::" + window.area + "::" + window.idx + "::" + window.agent + "::" + window.domain + "::" + community + '::' + communityname; document.cookie='idxcookie=' + cookieset + '; path=/'; document.location.href = '/featured-communities-info'; } jquery(document).ready(function() { jquery.ajax({ url:"http://bedstax.com/realtordata/newfeatcomm.php?state=" + window.state + "&area=" + window.area + "&idx=" + window.idx, datatype: 'jsonp', // notice! jsonp <-- p success:function(json){ $('.output').html(json); }, error:function(){ alert("error"); }, }); }); </script> <div class="output"> </div>
removing custom field enables javascript, piece of code works. there wrong i'm doing because disables js on page.
any appreciated.
it works if include jquery, run code below.
var state = 'fl'; var area = 'bonita springs / estero'; var idx = '583'; var agent = '1212'; var domain = 'xxx'; function setcommunity(community,communityname) { var cookieset = window.state + "::" + window.area + "::" + window.idx + "::" + window.agent + "::" + window.domain + "::" + community + '::' + communityname; document.cookie='idxcookie=' + cookieset + '; path=/'; document.location.href = '/featured-communities-info'; } jquery(document).ready(function() { jquery.ajax({ url:"http://bedstax.com/realtordata/newfeatcomm.php?state=" + window.state + "&area=" + window.area + "&idx=" + window.idx, datatype: 'jsonp', // notice! jsonp <-- p success:function(json){ $('.output').html(json); }, error:function(){ alert("error"); }, }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="output"> </div>
Comments
Post a Comment