Hello, I am attempting to use AJAX in jQuery to load content to a div, however, it is severely failing:
Here's the javascript:
$(document).ready(function() {
$('#webdev').hide();
$("#apply-webdev").click(function() {
var form = $("#webdev");
var formContent = form.find("#webdev");
form.slideToggle();
$.ajax({
url: "api.php?do=get_form_webdev",
cache: false,
success: function(data) {
form.html(data.params);
},
dataType: "json"
});
});
});
And here's the HTML:
<div class="rbutton"><button title="Apply for position" id="apply-webdev" onclick="load_webdev_form()"> Apply </button></div>
<div id="webdev">
<fieldset><legend>Apply for position</legend><div style='padding:10px; text-align:center'><img src='/images/load.gif'/></div></fieldset>
</div>
What am I doing wrong?
EDIT
Below is the new code, based on answers given in this thread:
$(document).ready(function() {
$('#webdev').hide();
$("#apply-webdev").click(function() {
$("#webdev").slideToggle();
$("#webdev").load("api.php?do=get_form_webdev");
});
$('#webdevcancel').click(function()
{
$('#webdev').hide('slow');
}
);
$('#webdevsave').click(function()
{
$('#webdev').block({
message: '<h1>Processing...</h1><img src="/images/load.gif" /><br /><br />',
css: { border: '3px solid #a00' }
});
}
);
});