php - Making a search of course/teacher with Ajax and jQuery -


i have jquery ajax problem.

i have select tag options of courses, select holds div id="course". have button id of "go" , empty div id of "courseinfo". need make when course number selected, teacher name in php file goes displayed on page. have ajax written, linked, wont work , no error when debug.

$(document).ready(function(){ findcourse = function(){  var file = "course.php?course="+$("#course").val();  $.ajax({     type: "get",     url: file,     datatype : "text",     success : function(response) {      $("#courseinfo").html(response);      }  });  }  clear = function(){     $("#courseinfo").html(""); };  $("#course").click(clear); $("#go").click(findcourse); }); 

form:

<form action="" method="post"> <select name="course" id="course"> <option value="420-121">420-121</option> <option value="420-122">420-122</option> <option value="420-123">420-123</option> <option value="420-221">420-221</option> <option value="420-222">420-222</option> <option value="420-223">420-223</option> <option value="420-224">420-224</option>  </select> select course see course name , teacher assigned<br><br> <input type="button" id="go" value="go!">  </form> <br><br> <div id="courseinfo"></div> 

assuming php side working properly, code below should fix issue.

$(document).ready(function(){     findcourse = function(){         var file = "course.php?course="+$("#course").val();         console.log(file);         $.ajax({             type: "get",             url: file,             datatype : "text",             success : function(response) {                 $("#courseinfo").html(response);              }         });      }      clear = function(){         $("#courseinfo").html("");     };      $("#course").click(clear);     $("#go").click(findcourse); }); 

you miss = in var file.

yours was

var file = "course.php?course"+$("#course").val();

it should be

var file = "course.php?course="+$("#course").val();


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -