I have a problem that my Js file is not recognizing a php variable built by ajax. Here is an example:
index.php:
<script src="js.js">
</script>
<?
include('build.php');
<div id="brand">
<?
   echo $brandinput;
?>
</div>
//....more code
?>
build.php:
<script type="text/javascript">
    $(document).ready(function(){
     $.ajax({
       crossOrigin: true,
       dataType: "jsonp",
       type: "GET",
       url: "getBrand.php",
       data: info,
       success: function(data){
             $("#result").html(data); 
       }
     });
     </script>
     <?php $brandinput='<div id="result"></div>'; 
      ?>
js.js:
$(document).ready(function(){
//dosomething with div's in index.php
}
So, I'll try to explain this in the easiest way. My index.php includes a build.php which as you can see calls ajax to retrieve data from another server. This data is located in a php variable ($brandinput) which will contain many <div>,<input>,... etc.  Then index.php echo $brandinput, showing all the content of the variable. But I have a js.js which change appearances in div's, input's, etc.. and is this js which is not recognizing the content of the variable $brandinput.
I'd like to know if you have more ideas or what am I doing wrong...
All the code is working well, I tested many times (except for what I said before)
The ajax call work well and Index.php displays $braninput correctly.
p.s. $brandinput is something like this: 
<div id='BlackBerry'><img src='..\/images\/supporteddevices\/blackberry-logo.jpg' alt='blackberry-logo' width='75'><br><input class='adjustRadio' type='radio'
and yeah it works well too.
 
     
     
    