title: React JS get json data and print in text field with perticular selected ID
body: <p>This react code I am writing for accepting the data from <code>test.php</code></p>
  
  <pre><code>  var BasicInputBox = React.createClass ({
                      render: function (){
              //getting the input field to display the details
                        return (
                         &lt;div&gt;
                          &lt;tr&gt;&lt;td&gt;
                            &lt;label&gt;{this.props.label}&lt;/label&gt;&lt;/td&gt;
                             &lt;td&gt;&lt;input type="text" onChange = {this.props.valChange} value = {this.props.value}/&gt;&lt;/td&gt;
                          &lt;/tr&gt;
                         &lt;/div&gt;
                        );
                      }
                  });
                  var DataInTableFormat = React.createClass({
                      getInitialState: function() {
                        return {
                          phpData : [],//initialize the data and the id
                          id : ''
                        };
                      },
                      componentDidMount: function() {
                        var url = document.URL;  
                        var currentId = url.substring(url.lastIndexOf('?') + 4);//getting the current ID of the student to and send it to the test.php through AJAX.
                        var data = {
                        idtoUpdate: currentId
                        };
                        $.ajax({
                          type: 'POST',
                          url: 'test.php',
                          data: data
                          })//post the ID through AJAX to test.php this will works fine.
                          .done(function(data) {
  
                          })
                          .fail(function(jqXhr) {
                          console.log('failed to register');
                          });
  //getting the data returned from the test.php
                        $.get(this.props.source, function(result) { ////storing the JSON data in result
                            var collection = JSON.parse(result); // //coverting JSON data to Javascript object
                            if (this.isMounted()) {//checking for component mount.
                              this.setState({
                                phpData: collection //collecting the all JSON data
                             });
                            }
                          }.bind(this));
                        },
                      fetchData : function(){
                        console.log("onClick fetch")
                      },
                      nameChange: function(event){
                           this.setState({name: event.target.value})
                      },
                      render : function(){ 
                        DBdata = this.state.phpData || [];
                        return(
                          &lt;div&gt;
                                &lt;table&gt;
                                  {DBdata.map(function(d){
                                   return(
                                      &lt;BasicInputBox label="Student Name :" valChange={this.nameChange} value={d.name}/&gt;
                                      )}
                                   )}
                                      &lt;tr&gt;&lt;td&gt;&lt;td&gt;&lt;button name="fetch" value="fetch" onClick={this.fetchData}&gt;fetch&lt;/button&gt;&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
                                      &lt;tr&gt;&lt;td&gt;&lt;td&gt;&lt;button name="submit" value="submit"&gt;update&lt;/button&gt;&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
                                   &lt;/table&gt;
                                &lt;/div&gt;
                            )
                        }
                     });
                    React.render(
                      &lt;DataInTableFormat source="http://localhost/PHP-React-Demo/test.php" /&gt;,
                        document.getElementById('Table-data')
                      );
  </code></pre>
  
  <p>When I am changing the path to the index.php(which prints the all data in a JSON form it works nice. And when test.php(which returns the single student information then I am getting the error</p>