Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
🚀 Google AI PRO – 18 Months | Rs. 850 Only
lkkolla
Updated:
Today at 4:56 PM
🔒 NordVPN Premium – 3 Months
hrdilshan
Updated:
Thursday at 8:29 PM
🚀 Microsoft Office 365 Pro Plus – Lifetime Access! 🚀
hrdilshan
Updated:
Thursday at 8:28 PM
Linkedin Premium Business / Careere /Sales Navigator - 1/2/3/6/9/12 Months - Reddem Link
hrdilshan
Updated:
Thursday at 8:27 PM
Colombo
YEYE 3 in 1 Instant Coffee Mix 50 Sachet
Romeshka
Updated:
Wednesday at 12:16 AM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Java Script help එකක්!!!
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="ishan0001" data-source="post: 21845084" data-attributes="member: 262672"><p><span style="font-size: 12px">මුලින්ම API call එකක් දානව country data ටික variable එකකට ගන්න. ඒකට use කරන්නෙ GetJSON. ඒකට url එකයි callback function එකකුයි දාන්න ඕන. Data ටික ආවොත් ඒ ටික දාල callback function එක call වෙනව. ඒක ඇතුලෙ ලියල තියනව data json එකේ හැම object එකකටම අදාලව dropdown එකට option element එක ගානෙ add කරන්න කියල. ඔය ටික ඔක්කොම කරන්නෙ document ready උනාම. ඒ කියන්නෙ page එක ලෝඩ් වෙලා ඉවර උනාම.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">ඊලගට dropdown එකෙන් කැමති රට තෝරල button එක click කලාම populate function එක call වෙනව. ඒකෙ ලියල තියෙන්නෙ dropdown එකේ select කරල තියන value එක name එක විදියට තියන json එක return කරන්න කියල. මේකෙන් ඇත්තටම return වෙන්නෙ අදාල json එක විතරක් තියන json array එකක්. ඒ නිසා අපිට අදාල json object එක refer කරන්න json array එකේ 0th index එක ගන්න වෙනව (<span style="color: #000000">selectedCountry[0]</span>). ඒකෙත් callingCodes කියන්නෙ තව json එකක්. ඒකෙ 0h index එකේ තමයි අවශ්ය dial code එක තියෙන්නෙ. ඊට පස්සෙ alert එකක් දාල ඒක display කරන්න තියෙන්නෙ.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">api එකෙන් country එකේ තව ගොඩක් විස්තර එනව. ඒ නිසා api response එක ටිකක් bulky. ඔය මට්ටමේ program එකක් performance critical නැති නිසා ඒක අව්ලක් වෙන්නෙ නෑ. optimize කරන්න ඕනම නම් country code එකයි dial code එකයි විතරක් දෙන api තියෙනව ඒකක් use කරන්න. ඔය වැඩේට විතරක් නම් data ටික databse එකක දාගෙන නටන්න ඕන නෑ.</span> <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /><img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></p><p style="text-align: center"><span style="color: #FFFFFF">Save</span></p></blockquote><p></p>
[QUOTE="ishan0001, post: 21845084, member: 262672"] [SIZE=3]මුලින්ම API call එකක් දානව country data ටික variable එකකට ගන්න. ඒකට use කරන්නෙ GetJSON. ඒකට url එකයි callback function එකකුයි දාන්න ඕන. Data ටික ආවොත් ඒ ටික දාල callback function එක call වෙනව. ඒක ඇතුලෙ ලියල තියනව data json එකේ හැම object එකකටම අදාලව dropdown එකට option element එක ගානෙ add කරන්න කියල. ඔය ටික ඔක්කොම කරන්නෙ document ready උනාම. ඒ කියන්නෙ page එක ලෝඩ් වෙලා ඉවර උනාම. ඊලගට dropdown එකෙන් කැමති රට තෝරල button එක click කලාම populate function එක call වෙනව. ඒකෙ ලියල තියෙන්නෙ dropdown එකේ select කරල තියන value එක name එක විදියට තියන json එක return කරන්න කියල. මේකෙන් ඇත්තටම return වෙන්නෙ අදාල json එක විතරක් තියන json array එකක්. ඒ නිසා අපිට අදාල json object එක refer කරන්න json array එකේ 0th index එක ගන්න වෙනව ([COLOR=#000000]selectedCountry[0][/COLOR]). ඒකෙත් callingCodes කියන්නෙ තව json එකක්. ඒකෙ 0h index එකේ තමයි අවශ්ය dial code එක තියෙන්නෙ. ඊට පස්සෙ alert එකක් දාල ඒක display කරන්න තියෙන්නෙ. api එකෙන් country එකේ තව ගොඩක් විස්තර එනව. ඒ නිසා api response එක ටිකක් bulky. ඔය මට්ටමේ program එකක් performance critical නැති නිසා ඒක අව්ලක් වෙන්නෙ නෑ. optimize කරන්න ඕනම නම් country code එකයි dial code එකයි විතරක් දෙන api තියෙනව ඒකක් use කරන්න. ඔය වැඩේට විතරක් නම් data ටික databse එකක දාගෙන නටන්න ඕන නෑ.[/SIZE] :):) [CENTER][COLOR=#FFFFFF]Save[/COLOR][/CENTER] [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom