You are using
school_id and
teacher_id for 3 different things:
The elements ID's
The identifiers for the passed variables
and for the in-function defined variables
Though it doesn't seem to whats causing the trouble in this case, it can be very hard to remember, what is what.
A good thing is to make some differences between the names.
e.g.:
The ID's with Initial caps
Code:
<input type="button" onclick="ajaxFunction('School_Id','Teacher_Id')" value="Add Favourite"/>
The identifiers in lower-case
Code:
function ajaxFunction(school_id,teacher_id){
and the variables in upper-case
Code:
var SCHOOL_ID = document.getElementById('school_id').value;
var TEACHER_ID = document.getElementById('teacher_id').value;
var queryString = "?sid=" + SCHOOL_ID;
queryString += "&tid=" + TEACHER_ID;
beside that, the only problem I can see is that though you passed the id's to the function you are using predefined id's when creating the variables:
Code:
var SCHOOL_ID = document.getElementById('school_id').value;
var TEACHER_ID = document.getElementById('teacher_id').value;
change it so it refers to the identifiers instead:
Code:
var SCHOOL_ID = document.getElementById(school_id).value;
var TEACHER_ID = document.getElementById(teacher_id).value;