Return and print value passed through php script from javascript object using jquery ajax

i have the following code: Javascript object:

 var getDBresults = (function () {  
    function getResult(url,TableName ,callback){
            url: url,
            type: 'POST',
            data: {
            dataType: 'json',
            success: function(data){

            error: function(){}
    return {
        getAllVideoes: function(){
            getResult("getAllResults.php", "videoer", function(data){
                return data;


simple php script:


    $tableName = $_REQUEST['table'];

    echo $tableName;

My js command for fetching(seperate script ofc):

    var obj = getDBresults;
    var data = obj.getAllVideoes();

My issue is with the callback function. It wont output anything and it doesn't seem to be running at all.. Had this issue for quite som time now and i just cant figure it out.. Is there anything i'v been missing? All help is apriciated! Sorry for my spelling btw.


you ajax is expecting

`dataType: 'json',`

json output from your php script

you are returning html/plaintext data

`echo $tableName;`

try json_encode

echo json_encode(array($tableName)); 

result is not in JSON format, so when jQuery fails to parse it,

You can catch the error with ajax's error: callback function

Need Your Help

Java Micro Edition (J2ME) - Update Record using recordstore enumeration

java java-me midp rms

I have a record store of items which have (name, quantity, owner, status)

Styling radio button without label

javascript html css checkbox radio-button

I am now facing this problem: I want to style radio buttons and checkboxes that are generated by system and do not have a label.