If $f(x,u(x))$ measuable with conditions recently, I've encountered a question about measurable function. after I've searched in MSE, it's been asked in a similar way before, but curiously the answer is the same as I've considered to be wrong. the link is here, so what is the right answer?
copy the question as follows:

Given $f(\cdot, y)$ is measurable for each $y$, $f(x, \cdot)$ is
  continuous for each $x$. If $u(t)$ is continuous, how can I show that
  the function $f:[0,1]\times \mathbb{R} \rightarrow \mathbb{R}$ defined by $f(t, u(t))$ is
  measurable?

The problem of the answer lies in "The continuous of $f$ is unknown", $f(x,u)$ is continuous only for specified $x$, not for all variables. Although the answer is correct in its own way, but no use for the question.
 A: To put this into a little context, a function $f:\Omega\times \Bbb R^n\to\Bbb R$ such that $f(\cdot,a)$ is measurable for almost every $x\in\Omega$ and that $f(x,\cdot)$ is continuous is call a Caratheodory function. This kind of function is commonly encountered in Calculus of Variation.
The proof usually goes like this: Let's define 
$$
g(x) := f(x,u(x)),
$$
where $u$ is a simple function
$$
u(x)=\sum_{i=1}^m a_i \mathbf 1_{E_i}(x)
$$
where $E_i$ is a measurable set (I know $u$ is not continuous but please bear with me for a second). For any $t\in\Bbb R$, observe that 
$$
\{x\in\Omega : g(x)<t \} = \bigcup_{i=1}^m \{ x\in E_i : f(x,a_i)<t \}.
$$
Since we know that $x\mapsto f(x,a_i)$ is measurable, each set on the right hand side is measurable which implies that $g=f(\cdot,u(\cdot))$ is a measurable function.
In general, let $u$ be any measurable function then we can find a sequence $u_n$ of simple functions such that $u_n\to u$ almost everywhere. By continuity of $a\mapsto f(x,a)$ (almost every $x$), we have
$$
\lim_{n\to\infty} f(x,u_n(x)) = f(x,u(x)) = g(x)
$$
for almost every $x$. This shows that $g$ is a the (almost everywhere) limit of a sequence of measurable functions, hence $g$ is itself measurable.
The case where $u$ is continuous follows immediately.
