Tuesday, 15 May 2012

javascript - ajaxComplete - how to call/trigger? -



javascript - ajaxComplete - how to call/trigger? -

how trigger function when ajax response complete?

on alter of drop downwards manageimagesdynamicobjectdetails function called:

<select id="imagecomponentselection" name="imagecomponentselection" onchange="manageimagesdynamicobjectdetails()">

this function passes variables related ajax phone call makerequests function.

function manageimagesdynamicobjectdetails(){ var sendcontent = "selection=".concat(document.getelementbyid('imagecomponentselection').value); var filename = "retrieveobjectsinformation"; var elementid = "objectdata"; if(sendcontent != "select class view components"){ makerequest(filename,sendcontent,elementid); } }

makerequest function called ajax calls , deals them appropriately.

function makerequest(filename,sendcontent,elementid) { var xmlhttprequest = getxmlhttprequest(); xmlhttprequest.onreadystatechange = getreadystatehandler(xmlhttprequest,elementid); xmlhttprequest.open("post", filename, true); xmlhttprequest.setrequestheader("content-type", "application/x-www-form-urlencoded"); xmlhttprequest.send(sendcontent); }

when speicif ajax phone call finish want phone call resizeobjectlist function.

function resizeobjectlist(){ var windowheight = $('#contentwrapper').height(); var newobjectlistheight = windowheight - 53 - 20 - 20 - 60; var element = document.getelementbyid("componentobjectlist"); if (typeof(element) != 'undefined' && element != null){ document.getelementbyid("componentobjectlist").style.height = newobjectlistheight; } }

how do this? i've tried ajaxcomplete , ajaxstop not them trigger.

i beleive want somthing like: response = xmlhttprequest.responsetext;

bute above works if create ajax async. read: http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp

if utilize jquery, makes ajax lot more simple: http://api.jquery.com/jquery.ajax/

here example:

$.ajax({ url: "http://fiddle.jshell.net/favicon.png", type: "get" data: "key0=val0&key1-val1" }).done(function( info ) { alert(data) });

javascript jquery ajax

No comments:

Post a Comment