1

I have made a php file that takes ajax calls so I can return things from a database. But I have some issues getting the JQuery side to work.

function phpFunction(funktion, callback){
    $.ajax()({
        global: false,
        url: "./system/functions.php?ajax="+funktion,
        success: callback
    });
}

and I try to run it with this

phpFunction("getImageUrl()",function(data){
        alert(data);
    });

But nothing happens, I don't even get an empty alert back.

1 Answer 1

1

Looks like a simple syntax error. This...

$.ajax()({

should be this...

$.ajax({

I'd also use set a request method (POST / GET / etc) and use the data param...

$.ajax({
    url: 'system/functions.php',
    type: 'GET',
    global: false,
    data: { ajax: funktion },
    success: callback
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks again, I didn't how to write the data param, I'm new to javascript, and jquery

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.