Get result PHP code in jQuery function?
<p>I use codeigniter and i want make uniqid code with php as following code(by random_string()):</p>

<pre><code>function coding(){
    echo random_string('unique');
}
</code></pre>

<p>I want use result top function in a, jquery function (for use in js code), i in jquery code try as this, but this output in <code>alert(coding())</code> is "undefined". How can fix it?</p>

<pre><code>function coding(){
   $.ajax({
        type: "POST",
        dataType: "text",
        url: "coding",
        cache: false,
        success: function (data) {
            return data;
        }
   })
}
alert(coding()) // in here output is  "undefined" !!!?
</code></pre>
