javascript - in wordpress request.open('GET', 'data.json',true); not working. why? -


hi making wordpress plugin can bring names of products json file if writes products name search bar. think data.json not getting ajax in wordpress. path defining syntax error guess.

$.getjson('data.json', function(data)

following complete scripting code , working fine in php website not in wordpress.: `jquery('#search').keyup(function(){

var searchfield = jquery('#search').val(); var myexp = regexp(searchfield,"i"); jquery.getjson('data.json', function(data){      var output= '<ul class="searchresult">';     jquery.each(data, function(key, val){         if((val.name.search(myexp) != -1) || (val.category.search(myexp) != -1)){             output += '<li>';             output += '<h2>' + val.name + '</h2>';              output += '<img src="images/'+val.image+'.jpg" alt="sorry image"/>';              output += '<p>' + val.category + '</p>';             output += '</li>';         }     });     output += '</ul>';     $('#update').html(output);   }); 

}); `

1: file "data.json" should in root of folder along wp-config.php file 2: check .htaccess if can access "data.json" file 3: in wordpress jquery version, can use jquery instead of $ , can see using $("#update") , change jquery("#update")

    jquery('#update').html(output); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -