javascript - Get querystring and send to other file script -
how send query string on checkfolder.php?
want use query string in checkfolder.php, don't know how querystring have value in checkfolder.
i need echo out query string in checkfolder.php.
script: have $_get['location'] querystring.
// function querystring function geturlvars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } // function run checkfolder every 5 second. $(document).ready(function () { setinterval(function() { // code goes here run every 5 seconds. var txt = ''; var first = geturlvars()["location"]; $.ajax({ type: "post", url: "checkfolder.php", success: function(result) { if(parseint(result) == "1") { location.reload(); } else { } } }); }, 5000); });
i checkfoler.php checkfolders file changes. in file need write this:
if ($filesfound == false) { $location = $_get['location']; $dir = "../img/uploads/".$location."/"; if (!is_dir_empty($dir)) { $filesfound = true; } }
you can pass parameter request like
$.ajax({ type: "post", url: "checkfolder.php", data: { location: geturlvars()["location"] }, success: function(result) { if(parseint(result) == "1") { location.reload(); } else { } } });
and can read data in php code. not php expert check out ---> http://php.net/manual/en/reserved.variables.post.php
something $location = $_post['location'];
. see these deprecated.