Created
February 12, 2018 03:55
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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