javascript - modifying html content on android phonegap application -


I have the following code that brings all the contacts from the device, and displays them in a table. Function Backout allContacts () {var htmltd; Var filter = ["displayName", "phone number", "email"]; // field navigator.cont.find (filter, function (contact) {// contactList = JSON.stringify (contact); alerts ('found' + contacts.length + 'contact'); (var i = 0; I & lt; Contact.length; i ++) {html5 + = '& lt; tr & gt; & lt; td & gt;' + contact [i] .displayName + '& lt; / td & gt; Lt; td & gt; '+ contact [i] .phoneNumbers [0] .value +' & lt; / td & gt; & lt; td & gt; '+ contact [i] .mail [0] .value + & Lt; / td & gt; & lt; / tr & gt; ';} if (htmltd ==' ') {Warning (' array populated empty '); and {document.getElementById ("tablebody"). InnerHTML = htmltd;}}, on error, {"multiple": true}); Function on error (contact error) {warning ("error =" + contactError.code); }

}

Note: This function is called when a button is clicked when the page is fully loaded

Cordova: Cordova -3.1.0

PhoneGrap: PhoneGap -2.2.0

This works perfectly well on virtual emulators, but when Tested on a real device (two devices tested on Android) it brings contact but the html content of 'tableys' has not been modified. Sector try

  $ ( '# tablebody'). Html (htmltd)   

but still does not work, and no error appears in the console and also in logcat .

You do this for :

  html5 + '' & lt; Tr & gt; & Lt; Td> Inside there is a very long convergence; + Contact [i] .displayName + '& lt; / Td> & Lt; Td> + Contact [i] .phoneNumbers [0] .value + '& lt; / Td> & Lt; Td> + Contact [i] .mail [0] .value + '& lt; / Td> & Lt; / Tr & gt; ;   

Perhaps some fields are not on the real device, think about the email or phone number . You firmly believe them that there is a zero-indexed value.

Javascript is likely throwing an undefined error.

Divide that line into sections.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -