I am integrating a PHP Site into my Wordpress Installation with a Plugin. This is working fine. Now I tried to update a dropdown list with data from a mySQL DB using a "jQuery":
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#parent_cat").change(function() {
jQuery(this).after('<div id="loader"><img src="img/loading.gif" alt="loading subcategory" /></div>');
jQuery.get('loadsubcat.php?parent_cat=' + $(this).val(), function(data) {
jQuery("#sub_cat").html(data);
jQuery('#loader').slideUp(200, function() {
jQuery(this).remove();
});
});
});
});
</script>
the html part:
form method="get">
<label for="category">Hauptkategorie</label>
<select name="parent_cat" id="parent_cat">
<?php while($row = mysql_fetch_array($query_parent)): ?>
<option value="<?php echo $row['cat_id']; ?>"><?php echo $row['category']; ?></option>
<?php endwhile; ?>
</select>
<br/><br/>
<label>Unterkategorie</label>
<select name="sub_cat" id="sub_cat"></select>
</form>
When calling the page with the "normal" (www.mysitename.com/wp-content/themes/theme/upload.php) URL then everything is working fine. But when I call the page from the "Wordpress - URL" (www.mysitename.com/upload) then the second dropdown list will never be populated.
Do I have to call the routine below alltough I am integrating a php side into my wordpress application?
<?php
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
?>
Kind Regards,
Stefan
</div>