检查文件加载时是否将$ _GET数据抛入页面[重复]

This question already has an answer here:

How do I know if a $_GET variable has been thrown in my page using jQuery? My $_GET variable is:

?ok=ok

I need to detect if the $_GET['ok'] is set using jQuery but I don't know how.

</div>

You could just check using PHP if $_GET['ok'] is set, then echo that into a JavaScript variable:

var ok = <?php echo intval(isset($_GET['ok'])) ?>

You can use the following which was taken from How to get the value from URL Parameter?

var QueryString = function () {
  // This function is anonymous, is executed immediately and 
  // the return value is assigned to QueryString!
  var query_string = {};
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    // If first entry with this name
    if (typeof query_string[pair[0]] === "undefined") {
      query_string[pair[0]] = pair[1];
      // If second entry with this name
    } else if (typeof query_string[pair[0]] === "string") {
      var arr = [ query_string[pair[0]], pair[1] ];
      query_string[pair[0]] = arr;
        // If third or later entry with this name
    } else {
      query_string[pair[0]].push(pair[1]);
    }
  } 
  return query_string;
} ();

then you can check if $_GET['ok'] is present in url with:

if(query_string.ok !== undefined){
    //$_GET['ok'] is in url
}