jquery - Ajax query not connecting to php file -


hi ask if doing right way code ajax jquery. prior applying ajax, code functioning way expected not seem update database. hope me. novice in ajax here.

echo "<form method='post' enctype='multipart/form-data' id='test_ajax'>";      echo "<select name='id' id='form-option' class='test-only'>";      echo '<option selected="selected">' .'choose user'. '</option>';            foreach ($registeredusers $key => $value) {        $registered = jfactory::getuser($value);        echo '<option value="'.$registered->id.'">'.$registered->name.'</option>';              }      echo "</select>";      echo "<input name='uploadedfile' type='file' id='custom-file-input' class='test-only' /> <br/>";      echo '<input type="submit" name="submit" value="upload" id="custom-submit-input" disabled="disabled" >';        echo "</form>";

here jquery script. trying connect process.php

jquery(document).ready(function() {         jquery('#test_ajax').submit(function(e){          		e.preventdefault();          		var user_name = jquery("#id").val();          		var user_file = jquery("#uploadedfile").val();          		var datastring = 'name=' + user_name + 'file=' + user_file;            			jquery.ajax({          				type: "post",          				url: "process.php",          				data: datastring,          				success: function(){          					sweetalert("you have successfuly uploaded file.");           				}          			});          		          		return false;          	});       });

here process.php file. can't find error in ajax query

$target_dir = "../portal-files/";  $target_file = $target_dir . basename($_files["uploadedfile"]["name"]);  $uploadok = 1;    // check if file exists  if (file_exists($target_file)) {      echo "sorry, file exists.";      $uploadok = 0;  }  else  {    if(isset($_post['id']))      {        $selectedvalue = $_post['id'];                $db = jfactory::getdbo();              $query = $db->getquery(true);                $query = "insert table1 (user_id) values ($selectedvalue)";                $db->setquery($query);              $result = $db->execute();      }    else {          echo "sorry, there error uploading file.";      }  }

try this..

  data: { name: user_name , file: user_file},    if(isset($_post['name'])) 

Comments