I've been using Ajax
for a little over a month, and I've been converting a lot of my documents to use JQuery/Ajax
. I've found a lot of the code is redundant, so I've been copy/pasting from one doc to another. Tonight though, after copy/pasting some Ajax
code, I forgot to change the url
to the reflect the doc i pasted to. But when I ran it, the code worked, using the ajax's
data
to call the PHP
from the other document. While this worked well and certainly cuts down on file size and a lot of copy/pasting, I need to know if this is bad practice?
For example, my working document is wsparticipation.php
:
function loadgroups() {
$.ajax({
url: 'wsparticipation.php',
type: 'POST',
async: false,
data: { 'setgroups': 1 },
success: function(re) {
$('#groupid').html(re);
}
});
}
And a function just below it, one I pasted from wsmonthlyreport.php
, uses the url : wsmonthlyreport.php
. And I didn't copy the getmonth
or getyear
"procedures" to wsparticipation.php
, yet it works as if I did.
function loadmonthyear(){
$.ajax({
url: 'wsmonthlyreport.php',
type: 'POST',
async: false,
data: { 'getmonth': 1 },
success:function(re) {
$('#showmonth').val(re);
$.ajax({
url: 'wsmonthlyreport.php',
type: 'POST',
async: false,
data: { 'getyear': 1 },
success: function(re){
$('#showyear').val(re);
}
});
}
});
}
So is this good or bad practice, calling procedures from another url
instead of the current url
?