0

I editted my ajax data but it still shows the old version while I am sure I saved it I even reopened the file and checked the location. It's like it is cached.

This is the actual code:

function setMessages(roomId, username, message){
    $.ajax({
        type: "get",
        url: "http://www.sinansamet.nl/chatdistract/ajax/setMessages.php",
        data: { roomId:roomId, username:username, message:message },
        success: function(html) {
                  strReturn = html;
                }
        });
}

But what it sees is

function setMessages(id){
    $.ajax({
        type: "get",
        url: "http://www.sinansamet.nl/chatdistract/ajax/setMessages.php",
        data: { id:id },
        success: function(html) {
                  strReturn = html;
                }
        });
}

Which was the old code.

The error is given in the console as "undefined id"

Sinan Samet
  • 6,432
  • 12
  • 50
  • 93
  • 1
    Ajax is Asynchronous. `return strReturn;` is happening before `strReturn = html;` happens. – Kevin B Jun 06 '13 at 19:52
  • Follow the post below for more details http://stackoverflow.com/questions/11576176/wait-for-a-jquery-ajax-callback-from-calling-function – user1889970 Jun 06 '13 at 19:54

2 Answers2

2

Do a browser refresh cache on most browsers it can be done by pressing CTRL + F5 Search google for clearing your browser cache.

user1889970
  • 726
  • 1
  • 8
  • 12
1

the a in ajax stands for asynchronous.

the function is returning before the callback of the ajax call is being called.

John Boker
  • 82,559
  • 17
  • 97
  • 130