[development] AJAX return values
Dan Robinson
dan at civicactions.com
Mon May 1 09:03:28 UTC 2006
thanks for the quick response. Is there some code you could point me at?
Thanks,
Dan
> Use drupal_to_js on the server and parseJson on the client to transfer
> serialized data in the server->client direction. I also like to send
> serialized JS to the server, but this requires external JSON libraries
> (both client and server side).
>
> -Robert
>
>
> Dan Robinson wrote:
>> I am trying to get some AJAX stuff to work -
>>
>> javascript function -
>>
>> function setMapContacts(uri, groupname) {
>> HTTPGet(uri+"/"+groupname, addContactsToMap, "") ;
>> }
>>
>> this is the PHP function that gets called as a result of the above
>> HTTPGet -
>>
>> function getContacts($GroupName) {
>> $contacts = getContactsInGroup($GroupName);
>> print drupal_to_js($contacts);
>> exit();
>> }
>>
>>
>> Here is the callback .js function I don't think I understand the
>> correct way to format the callback - "contacts" has no value -
>>
>> function addContactsToMap(httpresponse, xmlhttp, contacts) {
>> if (xmlhttp.status != 200) {
>> return alert('An HTTP error '+ xmlhttp.status +' occured.\n'+
>> httpresponse.uri); } ;
>> map.clearOverlays();
>> alert(httpresponse);
>> }
>>
>> and I get a dump in httpresponse - the dump has the data i want in it -
>> but I would much rather be dealing with a javascript array :). How do I
>> get a javascript array? Is there a cast I have to do?
>> Thanks,
>>
>> Dan
>>
>>
>
>
More information about the development
mailing list