0

I am trying to insert the value of parent into the "getFaculties()" function when i call the function using Ajax.

    function ajaxfunction(parent)
    {
        $.ajax({
            type: 'GET',
            url: 'Connection.php?getFaculties('+parent')',
            success: function(data) {
                $("#selFaculty").html(data);
            }
        });
    }
prasanth
  • 22,145
  • 4
  • 29
  • 53

4 Answers4

0

The correct syntax is

url: 'Connection.php?faculties='+getFaculties(parent),

Since that is query parameter, given a name to it.

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
0

use like this function Declaration was wrong

function ajaxfunction(parent)
    {
        $.ajax({
            type: 'GET',
            url: 'Connection.php?getFaculties='+getFaculties(parent),
            success: function(data) {
                $("#selFaculty").html(data);
            }
        });
    }
prasanth
  • 22,145
  • 4
  • 29
  • 53
0

please use a proper way to pass data from ajax to php

function ajaxfunction(parent)
    {
        $.ajax({
            type: 'GET',
            url: 'Connection.php',
            data: {method:'getFaculties', value:parent}
            success: function(data) {
                $("#selFaculty").html(data);
            }
        });
    }
Mudassar Zahid
  • 305
  • 2
  • 14
0

Call your function first and get return value in variable and then send your ajax request.

function ajaxfunction(parent)
{
    var data_in = getFaculties(parent);
    $.ajax({
        type: 'GET',
        url: 'Connection.php?getFaculties='+data_in,
        success: function(data) {
            $("#selFaculty").html(data);
        }
    });
}