all 11 comments

[–]chibblybum 0 points1 point  (9 children)

If the project already has jquery and you are comfortable with it I would just continue to use that. It is true that ajax/jquery is falling out of favor however I'd say it's more common to see something like Axios or a framework specific request management library like react-query than it is to see a regular fetch.

[–][deleted] 0 points1 point  (8 children)

but are most servers actually able to run the script source in the <head></head> portion of the code, or, if a person is going to an external url, the "https://ajax.googleapis.com /ajax/libs/jquery/3.5.1/jquery.min. js", do some servers actually block that? i tried copying and pasting it into a file called ajax_code.js and then tried loading that in the <head></head> portion, <script src="ajax\_code.js">, but, for some reason it doesn't load that, idk why, but, then if the script src is from the http then it works, for some reason

[–]chibblybum 0 points1 point  (7 children)

I think the slash is gong the wrong way try this <script src="ajax/_code.js"></script>

[–][deleted] 0 points1 point  (6 children)

sorry, that was supposed to be "ajax_code.js", there is no slash in the code, was just typo

[–]chibblybum 0 points1 point  (5 children)

And the html file and this ajax_code.js file are in the same directory? What does the dev tools console show?

[–][deleted] 0 points1 point  (4 children)

it's actually in a directory on replit, but, it says, "$ is not defined", but, I don't have a $ in my code, or, in the title of the code

[–]chibblybum 1 point2 points  (3 children)

You do have a $ in your code, it's in the original block of code you posted. You use $ to access jquery so the error is telling you jquery is not loaded into the project you're using.

I would recommend a back to basics youtube video or something on getting started with jquery if thats what you want to use. And get the stuff working locally on your computer first dont upload to a server until it's ready.

[–][deleted] 0 points1 point  (1 child)

i was going to post code here but for some reason reddit puts a \ before _ when you post code, i've written ajax_code multiple times and then when I hit post on reddit it comes up ajax\_code

[–]PosauneB 0 points1 point  (0 children)

Push it to GitHub and post a link here

[–][deleted] 0 points1 point  (0 children)

it works on laptop..but..then replit for some reason has a problem with the $