odd javascript behavior

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

odd javascript behavior

Jim Bodkins
Hi, I am not an experienced javascript coder. I need to do enough to
make an ajax/websockets app work. (Ajax at the moment). But I am
experiencing odd behavior.


This code:

app.getMessages = function() {
var fieldval;
  $.ajax({
    dataType: 'jsonp',
    url: app.backendUrl + '/ajax/get_messages',
    data: {field: fieldval, text: field.value},
    success: app.refresh,
    error: function() {
    },
  });
  window.setTimeout(app.getMessages, app.getMessagesIntervalMs);
};


... from a file on the server is arriving in the browser as:

app.getMessages = function() {
  $.ajax({
    dataType: 'jsonp',
    url: app.backendUrl + '/ajax/get_messages',
    data: {text: app.inputval},
    success: app.widget = app.inputval,
    error: function() {
    },
  });
  window.setTimeout(app.getMessages, app.getMessagesIntervalMs);
};




as a note ... app.refresh is ...

app.refresh = function(data) {
  $.each(data, function(index, entry) {
    var row = $('<div>').addClass('message-row').appendTo('#mml');
    var timestamp = (new Date(entry.timestamp *
1000)).toLocaleTimeString();
};


Where in the world did     success: app.widget = app.inputval,  come
from? Is this stable or is it me?

Thanks
Jim
_______________________________________________
dev-embedding mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-embedding