Results 1 to 1 of 1

Thread: Ajax/jQuery Post Data not working ?

  1. #1
    Join Date
    Aug 2009
    Thanked 0 Times in 0 Posts

    Question Ajax/jQuery Post Data not working ?

    Hello everyone,

    I do apologize if this is in the wrong forum, however I've made a Ajax/jQuery script to post form data, but the issue is that it gets to the loading message "Updating..." also I have "setTimeout" in place and when it reaches that timeout it still carrys on with the loading message, I'am using load() which is not the most constructive way as it doesn't handle errors but I aint here to discuss that.

    So the problem is, that when it reaches "setTimeout" it hangs and carrys on displaying the loading message?

    Here's my script:

    <script type="text/javascript">
    function procChgStMsg() {
      $('#msgSt').fadeOut(); //hide the set status message
      $('#editlink').fadeOut(); //hide edit link
    //Now we do the changing
    function chgStatusMsg() {
      $('#st_chg').fadeOut().css("display","none"); //hide the edit form and set display to none
      $('#myStatus').html('<img title="Processing..." src="ajax-loader.gif" /> Updating...'); //show a loading message
      setTimeout(function(){ $('#myStatus').load(ChgStatus()); }, 2000);
     function ChgStatus() {
     var http = new XMLHttpRequest();
     var stmsg = document.getElementById('st_msg').value;
     var user = "<?php echo $session->userinfo['username']; ?>";
     var url = "send.php";
     var params = "mood=" + escape(stmsg) + "&username=" + escape(user);"POST", url, true);
     //Send the proper header information along with the request
     http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     http.setRequestHeader("Content-length", params.length);
     http.setRequestHeader("Connection", "close");
       http.onreadystatechange = function() {
       if(http.readyState == 4 && http.status == 200) {
    I must add that the reason for different functions is because, there's a div with text, which is then faded out using "fadeOut();" and then the edit form is faded in using "fadeIn();" which resides where the text was first before the user-end clicked on the edit link.

    But as I said before it will not get to ChgStatus(), it will just hang on setTimeout();

    Hopefully someone can help me solve this, or even point me in the right direction any help is muchly appreciated.

    Thanks in advance!!!

    EDIT: Solved this
    Last edited by bennyy007; 08-10-2009 at 05:18 PM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts