Skip to content

Instantly share code, notes, and snippets.

@matdombrock
Created February 12, 2018 03:55
Show Gist options
  • Save matdombrock/79e5df6ac5803f3b655b5312df88d10f to your computer and use it in GitHub Desktop.
Save matdombrock/79e5df6ac5803f3b655b5312df88d10f to your computer and use it in GitHub Desktop.
URLSearchParams() does not work on mobile for iOS, this is an example of a workaround.
if ('URLSearchParams' in window) {
var urlParams = new URLSearchParams(window.location.search);
if(urlParams.has('id')){
var id = urlParams.get('id')
$.ajax({dataType: "json",url: "api.php?id="+id, success: function(result){
//ajax
}});
}
}else{
url = window.location.href;
url = url.split("?id=");
var urlParams = url[1]
if(urlParams != null){
var id = urlParams;
$.ajax({dataType: "json",url: "api.php?id="+id, success: function(result){
//ajax
}});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment