homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

error message not displaying in div

5+ Year Member

Msg#: 4343260 posted 3:44 pm on Jul 24, 2011 (gmt 0)

I am using php as a backend to check db duplicates and issue error message if no item was entered etc. My problem is that the message is coming back from php (firebug confirms this) but it is not appearing in the div. I would be gratful if someone could check my code and point out my error. The div for errors is: 'errorMessage'. Many Thanks

$('#BA_boxsubmit').click(function () {

var submit = $('#BA_boxsubmit').text();
var company = $('#BA_customer :selected').text();
var dept = $('#BA_dept :selected').text();
var box = $('.BA_box').val();
var service = $('#BA_service :selected').text();
var authorised = $('.BA_authorised').val();
var address = $('#BA_address :selected').text();
var data = 'submit=' + submit + '&company=' + company + '&dept=' + dept + '&box=' + box + '&authorised=' + authorised + '&service=' + service + '&address=' + address;
type: "POST",
url: "boxesadd.php",
data: data,
success: function (data) {
jAlert("You have successfully added\n\rBox: "+box+"\n\r"+
"Customer: "+company+"\n\r"+
"Department: "+dept+"\n\r"+
"Submit: "+submit, 'Box addittion successfull');

return false;



<div id="errorMessage"></div>

Relevant php code to appear in errorMessage div

if ($box == '')
echo '<div style="background-color:#ffa; padding:2px; color:#ff0000;font-size:12px;font-weight:normal">' . 'You must select a box for intake' . '</div>';



WebmasterWorld Senior Member 5+ Year Member

Msg#: 4343260 posted 5:05 am on Jul 25, 2011 (gmt 0)

data: data,
success: function (
data) {

try changing to

data: data,
success: function (
replyData) {

and sort out which other references to data should be to replyData


I do not understand success vs failure logic, does the message need to, or actually go to, all above locations ?


5+ Year Member

Msg#: 4343260 posted 8:55 am on Jul 25, 2011 (gmt 0)

hi dave. this line is for successfull submission: $('#BA_addbox').html(data);

and this line:
should show errors.

I have also changed the data as per your your suggestion, but still no change. The other funny thing, is that the jAlert is not firing nor are the fields being reset beforeclose.

autoOpen: false,
resizable: true,
modal: true,
title: 'Submit a box intake request',
width: 470,
beforeclose: function (event, ui) {
close: function (event, ui) {




WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

Msg#: 4343260 posted 1:06 pm on Jul 25, 2011 (gmt 0)

What does Firebug tell you about #errorMessage? Does it have style applied to it (or one of it's ancestors) that would prevent it from being visible (like display:none)?

If the jAlert dialog is not appearing, then it's also possible that jAlert is not recognized and that's causing a JavaScript error (which would prevent the rest of your success handler from running).


WebmasterWorld Senior Member 5+ Year Member

Msg#: 4343260 posted 1:17 pm on Jul 25, 2011 (gmt 0)

Add error handler similar to success handler
error: function () {

If it fires, check jQuery documentation on getting details of error.

Does the alert in the success function happen for successful submission ?

Does non successful submission return non 200 status code ?

I do not see any test for successful submission, it seems odd putting the reply in both #BA_addbox and #errorMessage' unconditionly.


5+ Year Member

Msg#: 4343260 posted 2:19 pm on Jul 25, 2011 (gmt 0)

jAlert is being recognised. even if put alert('whatever'); it still isn't being fired.

I am getting 200 status code. And yes you are correct about the addbox & errorMessage. Don't know why I did that.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved