Ajax WordPress pass post URLs

Yes that would be easy. You can use the get_the_permalink() function to retrieve a post’s link. Here’s how to do it:

// You are storing the post data here
$posts_arr[] = $post;

// Add the URL to the same array element
$posts_arr[]['url'] = get_the_permalink();

You can get the index of the current post in the loop by using the $query->current_post method, so I suggest you use that as the key of your array:

// You are storing the post data here
$posts_arr[ $query->current_post ] = $post;

// Add the URL to the same array element
$posts_arr[ $query->current_post ]['url'] = get_the_permalink();