In 1991, XJ speedo cables went away.
Here's the Wrangler cable I use on my MJs and XJs without cruise control. A little long but works well and has the white plastic clip at the speedo.
https://www.morris4x4center.com/speedometer-cable-53005084.html
Okay. Thanks.
Your Throttle Position Sensor is likely bad.
Can we squeeze the YEAR out of you also so we can be more specific addressing your issues?
Go to www.cruiser54.com and complete Tips 1 through 5 before doing anything else.
Could be a multitude of things.
Got a meter to test electrical stuff?
If so, go to my website and read about testing your CPS.
Tips 1,3,4 and 5 should be done anyway.