WordPress.org

Ready to get started?Download WordPress

Forums

dynamic path of theme in JS file (1 post)

  1. Alvaro
    Member
    Posted 2 years ago #

    Hello
    I have a function in javascript (JS) file where I need to give a path of a file along with variables, is there a way to get the theme path in a JS file,
    My code is

    // get  year list
    	function getyearlist(categoryId) {		
    
    		var strURL="http://localhost/plugin/wp-content/themes/EastCourt001/findyear.php?categoryId="+categoryId;
    		var req = getXMLHTTP();
    
    		if (req) {
    
    			req.onreadystatechange = function() {
    				if (req.readyState == 4) {
    					// only if "OK"
    					if (req.status == 200) {
    						document.getElementById('yearlistdiv').innerHTML=req.responseText;
    					} else {
    						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
    					}
    				}
    			}
    			req.open("GET", strURL, true);
    			req.send(null);
    		}
    	}

    I need to get this path dynamically
    http://localhost/plugin/wp-content/themes/EastCourt001/

    How Do I get the theme path in javascript file

    Thanks in advance

Topic Closed

This topic has been closed to new replies.

About this Topic