I am using jquery's ajax controls and the php files I am use dynamically create fields and dropdowns based on the information sent to the php file via get requests. The problem I am running into is that when php adds the form dynamically the dom is not updated to recognize the new dom elements.
Once the load request loads the dynamic data I need jquery to continue to manipulate these new fields, but jquery is not recognizing the new dom elements which makes the new dom elements like buttons static. and yes all the dynamic fields have their own unique id's/classes.
I have tried:
$("body").on("mouseover mouseout", "select", function(e){
$('#filelocations').change(function(){
var urlforcode = this.value;
var codeserial = encodeURIComponent(urlforcode);
$( "#containcontent" ).load("/include/adminarea.php?edittext="+codeserial);
});
<-- generic base code, but it only works some of the time.
My Question is how do I have jquery interact with elements that do not exist on the initial page load but will allow me to manipulate that data when loaded dynamically through .load requests?
Simple PHP Switch :
<?php
$statevariable = $_GET["stateSELECT"];
switch ($statevariable) {
case "AL":
echo '<p class="errorstyle margintopspacing" style="background:purple; color:white;">Some Pricing Data</p><button id="pricingsystem" class="btn btn-primary" >Click To Start Pricing</button>';
break;
case "AK":
echo "Switch1 ".$_GET["stateSELECT"];
break;
case "AZ":
echo "Switch2 ".$_GET["stateSELECT"];
break;
default:
echo "Switch3 ".$_GET["stateSELECT"];
}
?>
Simple Jquery Event:
$('#pricingsystem').click(function(){
console.log('The Stuff');
});