Most likely, removing the leading slash should resolve it.
url: "wp-admin/admin-ajax.php",
The leading slash tells the browser to look relative to the root of the site, where if it’s missing, then it will look relative to the location the calling object is running from.
Hi @codeispoetry, I’d suggest to use the built-in wp functions like plugins_url() then. Of course, you shouldn’t mix PHP and JS, but you might generate a simple JSON dictionary like e.g.
You could probably figure this out with some simple web searches (“javascript split”, “javascript slice”, “javascript join”) but essentially
“./” gets the URL for the object being run (you should have figured that out by now)
split takes that value and splits it into an array, split where “index” is
slice pulls the corresponding elements from the array, 0 is equivalent to array[0]is the starting position, -1 tells it to extract all of the array elements EXCEPT the last one (hence everything after the index)
join puts the array elements back into a string putting “index” as the separator - since you’ve only got one element, nothing got added to the string.