hd.
hd.

Reputation: 18306

display message on success return in ajax with jquery problem

i am using ajax with jquery .i have written this code:

   $.ajax({url:"myurl.php",
           data:datastr,
           type:"POST",
           success:function(data){
                      $("#msgbx").text(data);
           }
    });

it done what i want at the backend but doesn't show the return message in div with #msgbx id.

what is the problem?

Upvotes: 1

Views: 847

Answers (2)

Phil.Wheeler
Phil.Wheeler

Reputation: 16848

The problem may be related to the formatting or encoding of your returned JSON object, or it may be a failure on the server that occurs after all your other processing is done, but immediately before you return your data.

Without seeing any other code, try looking at the console window in either Firebug or Chrome's web development tools to see what your server is responding with. You should see an Ajax POST method logged to the console window. Assuming you don't have an error code shown there, check to see what sort of data is being returned (or if any is being returned at all).

If you are getting data back from the server, your problem is in how you're displaying that on the page / inserting it into the DOM. If on the other hand you aren't returning anything, you'll need to check your PHP code to see where other problems might exist in your logic.

Feel free to add more to your post so we can give more specific answers.

Upvotes: 1

Bhanu Prakash Pandey
Bhanu Prakash Pandey

Reputation: 3785

use $("#msgbx").html(data);

Upvotes: 0

Related Questions