This is a standard algebraic topology exercise, see solution of Problem 6 here.
Edit: Since this solution is likely to be used by people in order to do their homework in algebraic topology, I will phrase the solution as a sequence of steps, some minor details in which one would have to fill in in order to complete the homework. This way, one cannot simply copy the text below and present it as a solution.
Step 0. Define the following open subsets of $X=A*B$ and maps:
Define $U$, the union of segments $[a,b)$; $V$, the union of segments $(a,b]$, where $a\in A, b\in B$. Define $W=U\cap V$ and retractions $p: U\to A$, $p(x)=a$ where $x\in [a,b)$, and $q: V\to B$, $q(x)=b$ where $x\in (a,b]$. Also, fix points $a_0\in A, b_0\in B$ (here we use that $A$ and $B$ are nonempty).
Step 1. Show that $X$ is path connected using the fact that $B$ is path-connected and that you can connect every $x\in X$ to a point $b_0\in B$ via segment $[x,b]$.
In the following steps 2 through 6, assume that the set $A$ is also path-connected.
Step 2. Show that the retractions $p: U\to A, q: V\to B$ are homotopy-equivalences.
Step 3. Show that $W$ is homeomorphic to $A\times B\times (0,1)$. Conclude that $W$ is path-connected.
Step 4. Apply Seifert - Van Kampen theorem to conclude that $\pi_1(X)$ is generated by the subgroups
$$
i_*(\pi_1(A)), j_*(\pi_1(B))
$$
where $i: A\to X, j: B\to X$ are the inclusion maps. (Need to take care of the base-points here; how?)
Step 5 (the key). Show that the images of the maps $i_*, j_*$ are trivial using the fact that every loop $L$ in $A$ bounds the cone $L * b_0$. To fill in details one would need to extend (radially) the map $S^1\to L\subset A$ to a map of the disk $D^2\to L* b_0$, so that the center of $D^2$ is mapped to $b_0$. Same for loops $M$ in $B$ (using the point $a_0$ instead of $b_0$, of course).
Step 6. Conclude from 5 that $\pi_1(X)=1$.
We now drop the assumption that $A$ is path-connected, but assume (Steps 7 and 8) that $A$ is locally path connected (actually, you can just assume that $A$ is finite, see Step 10).
Step 7. Let $A_\alpha, \alpha\in J$, denote path-connected components of $A$. Then, by Step 6, we know that each $X_\alpha= A_\alpha * B$ is simply-connected. Therefore, the set $V_\alpha= V\cup X_\alpha$ is also simply-connected.
Step 8. Using local path-connectedness of $A$, show that each $V_\alpha$ is open in $X$. Then, again apply Seifert - Van Kampen theorem to the open cover $V_\alpha$ of $X$ (elements of which intersect along the connected subset $V$) to conclude that $X$ is simply-connected.
Now, consider the general case (not covered in the link).
Step 9. Let $g: S^1\to X$ be a loop. Show, using continuity of $g$, how to subdivide $S^1$ into arcs $c_k, k=1,...,m$ intersecting only at their end-points (which will be denoted $c_k^-, c_k^+$) such that:
a. The image (under $g$) of each $c_k^\pm$ is contained either in $A$ or in $B$.
b. The image (under $g$) of each $c_k$ is contained in $U$ or in $V$.
c. If the image of $g$ is disjoint from either $A$ or in $B$, no subdivision is performed: As in Step 5, such $g$ extends to a continuous map of $D^2$ to $X$.
Step 10. Suppose that $g(c_k)\subset U$. Using the radial extension as in Step 5, homotope the restriction $g|_{c_k}$ relative to its end-points to a map $f_k: c_k\to X$ whose image is the union of the intervals $[c_k^-, b_0]\cup [b_0, c_k^+]$. Do the same for arcs $c_k$ such that $g(c_k)\subset V$. As the result, obtain a new map $f: S^1\to X$ which is homotopic to $g$. The new map has the property that its image is contained in a joint $X_0=A_0 * B$, where $A_0\subset A$ is a finite subset (consisting of images of end-points $c_k^\pm$ and of the point $a_0$). Now, by Step 8, $f$ is null-homotopic in $X_0$; hence, $g$ is null-homotopic in $X$. QED