Van Pham Van Pham - 7 months ago 25
Javascript Question

Internal Server Error 500 in $.post jquery?

My Jquery code:

$(document).ready(function() {
$("#cat").change(function(e){
$.post($("#cat").val(), function(html){
$("#data").html(html);
});
return false;
});
});


My Html code:

<select name="cat" id="cat">
<option value="http://option1.html">Option 1</option>
<option value="http://option2.html">Option 2</option>
</select>
<div id="data">Hello World!</div>


But when i change selectbox to call ajax, I got Internal Server Error 500, please help me to solve?

Answer

If you are trying to get the contents of these html files, you should use $.get()

Like

$.get('out1.html')
  .done(function(data){
    $('#data').html(data);
  });
Comments