When calling wp_query via AJAX and passing a category ID and search parameter, the query does not return any posts. On page load, the query runs fine, which runs the same query.
If I add these variables directly in the JS or on the query itself, the query also runs fine.
I can also see the variables being set on the JS console when tested, so the issue would appear to be that they are not being passed via the AJAX request, but I'm struggling to see why as this runs on page load.
The "cat" variable is set by selecting a category (or multiple ones) via a side menu, then this is set as a string of IDs (1,2,3,4). The "0" value is set initially, so all posts are returned.
The "search" variable is taken from an input field.
I have attached the templates used for this, please can you take a look and add the line "I have looked at the files" to your quote, so I can filter out the blind quoters.