javascript - ForEach Array value in jQuery JSON result -



javascript - ForEach Array value in jQuery JSON result -

okay, want process javascript request foreach value returned within json response jquery request, here's current code i'm using request

function waitforevents(){ $.ajax({ type: "get", url: "/functions/ajax.php?func=feed&old_msg_id="+old_msg_id, async: true, /* if set non-async, browser shows page "loading.."*/ cache: false, timeout:50000, /* timeout in ms */ success: function(data){ var json = jquery.parsejson(data); **//foreach json repsonse['msg_id'] phone call function** settimeout('waitforevents()',"1000"); }, error: function (xmlhttprequest, textstatus, errorthrown){ alert("error:" + textstatus + " (" + errorthrown + ")"); settimeout('waitforevents()',"15000"); }, }); };

for each json response variable ['msg_id'] want phone call javascript function don't know how process array using foreach in javascript, thought how ?

as you're using jquery, can utilize $.each function:

http://api.jquery.com/jquery.each/

$.each(json.msg_id, function (index, value) { // value here, e.g. alert('value ' + index + ' ' value); })

javascript jquery ajax arrays foreach

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -