Basically if have this that works. It opens a query dialog box
$("#opener").click(function() {
$.ajax({
url: "hello.php",
success: function(data) {
$("#dialog").html(data).dialog("open");
}
});
$("#dialog").dialog({
bgiframe: true,
autoOpen: false,
height: 400,
width: 400,
modal: true
});
});
I want to call it from a
onClick="callMyFuncion(withDetails);
and basically send an ajax get request with myDetails.. heres what I’m trying
function getDayDetails(details) {
$.ajax({
type: "GET",
data: details,
url: "hello.php",
success: function(data) {
$("#dialog").html(data).dialog("open");
}
});
$("#dialog").dialog({
bgiframe: true,
autoOpen: false,
height: 400,
width: 400,
modal: true
});
};
and calling it from here
<td class="everyday" onClick="getDayDetails(monthID=<?php echo $month; ?>&dayID=<?php echo $day_num; ?>&yearID=<?php echo $year; ?>);">
I’m new to Javascript/ Jquery.. Thanks for any help
I believe you opted to use inline JavaScript since there was no way at hand for you to make it dynamic.
An alternative could be to use
data-*attributes to hold the date values. As shown below:And keep using the
.click()function instead of inlining JavaScript [as told] which should be better avoided.Passing
datato$.ajaxas an object has the advantage that jQuery will automatically encode the parameters.Finally, you can move the
.dialog()initialization to a.ready()function.