JQUERY combine two ajax calls
<p>I have got this html</p>

<pre><code>&lt;div class="headChat"&gt;&lt;/div&gt;
        &lt;input type="file" id="chatfil" accept="image/*" name="file_in"&gt;
        &lt;label for="chatfil"&gt;
            &lt;img src="../img/camera.png" class="addphc"&gt;
        &lt;/label&gt;
</code></pre>

<p>and this jquery</p>

<pre><code>$(".Mesform").submit(function(){
        event.preventDefault();
        var val=$(this).siblings('textarea').val();
        var who=$(".headChat").text();
        var formData = new FormData($(".Mesform")[0]);
            if (val!="") { 
                $.ajax({
                    url: '../files/ajax.php',
                    type: 'GET',
                    cache: false,
                    contentType: false,
                    processData: false,
                    data:"ChatSent="+val+"&amp;sento="+who,
                    success: function (data) {
                        $(".ChatDiv").append(data); 
                    }
                });
                $.ajax({
                    url: '../files/ajax.php',
                    type: 'POST',
                    cache: false,
                    contentType: false,
                    processData: false,
                    data:formData,
                    success: function (data) {
                        alert(data);
                    }
                });
            }
       });
</code></pre>

<p>and this in ajax.php</p>

<pre><code>if(isset($_FILES['file_in']) &amp;&amp; isset($_GET['ChatSent'])){
            $file_new_name="";
            $file=$_FILES['file_in'];
            $file_name=$file['name'];
            $file_tmp=$file['tmp_name'];
            $file_size=$file['size'];
            $file_error=$file['error'];
            $file_extension=explode('.', $file_name);
            $file_extension=strtolower(end($file_extension));
            $allowed=array('jpg','png');
            if (in_array($file_extension, $allowed)) {
                if ($file_error===0) {
                    if ($file_size&lt;=2097152) {
                        $file_new_name=generateRandomString(15).rand(0,100).'.'.$file_extension;
                        $_SESSION['file_new_name']=$file_new_name;
                        $file_destination='../chatimg/'.$file_new_name;
                        if (!move_uploaded_file($file_tmp,$file_destination)) {
                        echo "&lt;p class='filerror'&gt;Error occurred.Please try again&lt;/p&gt;";
                        exit();
                        }
                    }
                }
            }
            $ChatText=$_GET['ChatSent'];
            $ChatText=htmlspecialchars($ChatText);
            $ChatText=trim($ChatText);
            $Sento=$_GET['sento'];
            $Idquery=$con-&gt;query("SELECT Id FROM users WHERE Username='$Sento'");
            $Idrow=$Idquery-&gt;fetch_row();
            $IdTo=$Idrow[0];
            if ($IdTo=="") {
                     echo "Error";
                }else{
                        $Insert=$con-&gt;query("INSERT INTO chat (Message,From_,To_,`Date`,img) VALUES('$ChatText','$NameId','$IdTo',NOW(),'$file_new_name')");
                        if($Insert){
                        ?&gt;  
                        &lt;div class="fm"&gt;
                                &lt;span&gt;&lt;?php echo $ChatText; ?&gt;&lt;/span&gt;
                        &lt;/div&gt;
                        &lt;br /&gt;
                        &lt;?php
                        } //if insert
                }
    }
</code></pre>

<p>When i separate $_FILES['file_in'] and $_GET['ChatSent'] the both work.But together they do not work.I can't separate them because i have to insert both of them into database</p>