Forum Moderators: open
Now, it displays the URL on my debug but it doesn't go any further. The URL exists and defiantly takes the post data, I double checked with a simple HTML form. Any ideas?
I would start by following the exact steps that the javascript would take to see if you can see why it is going wrong. Having a proper structure and some organization will help you through this.
Sorry I cannot be of anymore help. Perhaps posting he relevant AJAX would help?
Here's what happens:
A link that calls func addDes('id').
function addDes (picid) {
// make the form div visable
new Effect.Appear('imgdes-form');// make it draggable
new Draggable('imgdes-form');
// pass picid
$('imgdes-picid').value = picid;
}
Then, the 'id' is passed to a hidden input in an HTML form:
<div id="imgdes-form" class="ajaxbox" style="display:none;">
<div id="error" style="display:none;"><h3 id="errorh3"></h3></div>
<textarea name="imgdes-new" id="imgdes-new" cols="40" rows="5"></textarea><br />
<input name="imgdes-picid" id="imgdes-picid" type="hidden" value="" />
<input name="" id="imgdes-button" type="button" value="Submit" onclick="doDes();" />
</div>
Then when you submit, it calls func doDes().
function doDes () {
// let's get our data together first
var des = $('imgdes-new').value;
var picid = $('imgdes-picid').value;// add status
// check if error is already displayed
if ($('error').style.display = "none") {
$('error').style.display = "block";
}
// add status
$('errorh3').innerHTML = "Sending, please wait!";
// disable textarea and submit
$('imgdes-button').disabled = true;
$('imgdes-new').disabled = true;
// set opts
var opt = {
// use POST
method: "post",
// send this lovely data
postBody: "loginemail=<?=$_SESSION['loginemail'];?>&picid="+picid+"&des="+des+"",
// handles
onSuccess: function (request) {
if (request.responseText.indexOf('Failed')!= -1) {
// failed! display the error
$('errorh3').innerHTML = request.responseText;
} else {
// success! display the status
$('errorh3').innerHTML = request.responseText;
// change orignotes
$('imgdes').innerHTML = des;
// clear the textarea
$('imgdes-new').value = "";
// get rid of error
window.setTimeout('new Effect.SlideUp(\'error\')',1500);
// hide the form and show the button
window.setTimeout('new Effect.Fade(\'imgdes-form\')',500);
// restore textarea and submit
$('imgdes-button').disabled = false;
$('imgdes-new').disabled = false;
}
},
on404: function (request) {
alert('Error 404: location "' + request.statusText + '" was not found.');
},
onFailure: function (request) {
$('errorh3').innerHTML = request.statusText;
}
}
new Ajax.Request('ajax/updateimagedes.php', opt);
}
Any ideas?