Forum Moderators: open

Message Too Old, No Replies

Strange Problem

         

ahmedtheking

11:47 am on Jan 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've got an AJAX script, that seems to be going half way, but not quite there. This is what happens: the script does everything right and then sends the data to my PHP script via POST. Now AJAX nor JS report any errors, I've even double checked with defining responders on create (so i can see the URL) and on fail.

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?

eelixduppy

9:19 pm on Jan 5, 2007 (gmt 0)



Not quite sure. If you say no errors are produced from any side then you have a logical error somewhere, or you just forgot something. In either case an error won't be produced; these are the hardest types of errors to find.

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?

ahmedtheking

5:44 pm on Jan 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've gone all through it. I know that it's not the end script cos it works and cos AJAX isn't reporting anything, I'm stumped:

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?

ahmedtheking

10:58 am on Jan 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Fudge AJAX! I just did it as HTML form!