The diagnosis of ankylosing spondylitis (AS) can be complex, necessitating a comprehensive assessment of medical history, clinical symptoms, and radiological evidence. This multidimensional approach can exacerbate the clinical burden and increase the likelihood of diagnostic inaccuracies, which may result in delayed or overlooked cases. Consequently, supplementary diagnostic techniques for AS have become a focal point in clinical research. This study introduces an enhanced optimization algorithm, SCJAYA, which incorporates salp swarm foraging behavior with cooperative predation strategies into the JAYA algorithm framework, noted for its robust optimization capabilities that emulate the evolutionary dynamics of biological organisms. The integration of salp swarm behavior is aimed at accelerating the convergence speed and enhancing the quality of solutions of the classical JAYA algorithm while the cooperative predation strategy is incorporated to mitigate the risk of convergence on local optima. SCJAYA has been evaluated across 30 benchmark functions from the CEC2014 suite against 9 conventional meta-heuristic algorithms as well as 9 state-of-the-art meta-heuristic counterparts. The comparative analyses indicate that SCJAYA surpasses these algorithms in terms of convergence speed and solution precision. Furthermore, we proposed the bSCJAYA-FKNN classifier: an advanced model applying the binary version of SCJAYA for feature selection, with the aim of improving the accuracy in diagnosing and prognosticating AS. The efficacy of the bSCJAYA-FKNN model was substantiated through validation on 11 UCI public datasets in addition to an AS-specific dataset. The model exhibited superior performance metrics—achieving an accuracy rate, specificity, Matthews correlation coefficient (MCC), F-measure, and computational time of 99.23 %, 99.52 %, 0.9906, 99.41 %, and 7.2800 s, respectively. These results not only underscore its profound capability in classification but also its substantial promise for the efficient diagnosis and prognosis of AS.