Sunteți pe pagina 1din 4

11/07/2016 How to populate datas into a select box using jQuery ajax json, php

(http://www.appsntech.com/)

appsntech.com is a how to blog maintained by Sanjoy Dey. Tutorials are mostly focused on
HOME (HTTP://WWW.APPSNTECH.COM/)  |
PHP (HTTP://WWW.APPSNTECH.COM/P/PHP.HTML)  |

web applica on development, PHP Jquery, Ajax, AngularJS, Web Design, Web Development,
JQUERY (HTTP://WWW.APPSNTECH.COM/P/JQUERY.HTML)  |

Like Us
Magento, Javascript,Cygnite PHP Framework and MySQL etc.
FACEBOOK (HTTP://WWW.APPSNTECH.COM/P/FACEBOOK­TUTORIAL.HTML)  |

PROJECTS (HTTP://WWW.APPSNTECH.COM/P/PROJECTS.HTML)  | Open source We...
1,341 likes

How to populate datas into a select box
REQUEST TUTORIAL (HTTP://WWW.APPSNTECH.COM/P/REQUEST­TUTORIAL.HTML)  |

using jQuery ajax json, php
ABOUT (HTTP://WWW.APPSNTECH.COM/P/ABOUT­ME.HTML)  | WRITE FOR US (HTTP://WWW.APPSNTECH.COM/P/WRITE­FOR­US.HTML)
Like Page
 |
Share
CONTACT US (HTTP://WWW.APPSNTECH.COM/P/CONTACT­US.HTML)  |
+6   Recomende isto no Google
(htt (htt (htt (htt (htt Be the first of your friends to like this

2 Share 2  (http://feeds.feedburner.com/appsntech) Share   Compartilhar 6 Tweet


 
Curtir  

www.appsntech.com - Tech P…

Follow +1

Recent Posts

Travis CI: Continuous Integration for PHP
Project
(http://www.appsntech.com/2015/10/travis­ci­
continuous­integration­for­php­project.html)

More ­> (http://www.appsntech.com/2015/10/travis­ci­
continuous­integration­for­php­project.html)

Get Started With Test Driven Development:
Unit Testing With PHPUnit?
(http://www.appsntech.com/2015/09/get­
started­with­test­driven­development­unit­
testing­with­phpunit.html)

More ­> (http://www.appsntech.com/2015/09/get­
started­with­test­driven­development­unit­testing­with­
phpunit.html)

(http://1.bp.blogspot.com/­ 10 Best PHP Tools For Developers
(http://www.appsntech.com/2015/08/10­best­
tbcaB1uZIgE/VGZmLaYC0pI/AAAAAAAAArY/BssBTnfcZPs/s1600/facebook_style_autocomplete_u php­tools­for­developers.html)
sing_angular_js.png)
More ­> (http://www.appsntech.com/2015/08/10­best­
php­tools­for­developers.html)
If you are wondering how to populate select box using jquery ajax then you may find the
Backbone JS vs Angular JS­ Uncovering key
below post very simple and useful. differences
(http://www.appsntech.com/2015/08/backbone­
js­vs­angular­js­uncovering­key­
Retrieve values and populate the select box using jquery, ajax and PHP. differences.html)

More ­> (http://www.appsntech.com/2015/08/backbone­
js­vs­angular­js­uncovering­key­differences.html)

8 Brilliant Tools That Empower Web
Developers To Work With A Flair
(http://www.appsntech.com/2015/07/8­brilliant­
tools­that­empower­web­developers.html)

More ­> (http://www.appsntech.com/2015/07/8­brilliant­
tools­that­empower­web­developers.html)

About Me

(https://plus.google.com/1166798482081479531
28)
Sanjoy Dey
(https://plus.google.com/116679848208147953128)
Follow 278
You might also like
View my complete profile
Pay 1 cent per new visitor to your site
http://www.appsntech.com/2012/02/how­to­populate­datas­into­select­using.html 1/4
11/07/2016 How to populate datas into a select box using jQuery ajax json, php
Pay 1 cent per(https://plus.google.com/1166798482081479531
new visitor to your site
   Best fraud detection
28) in pay per click advertising + low bid prices = higher
   engines. Your solution to the Internet...
$.ajax({  www.payperranking.com
    type: "POST",  Support or Give Some Love Back
    url: 'http://www.appsntech.com/demo/rubro/list_ajax', 
    data: {'categoryID': $("#category").val(),'isAjax':true}, 
    dataType:'json', 
    success: function(data) { 
Advertise With Us Advertise With Us
       var select = $("#select"), options = ''; 
       select.empty();       

       for(var i=0;i<data.length; i++) 
       { 
        options += "<option value='"+data[i].id+"'>"+ data[i].name +"</option
>";                Advertise With Us
       } 

       select.append(options); 
    } 
}); 

And now in your server side page you may write below to fetch data from database.
Get Subscribe to Free Email Updates!!
   
  
Email address... Submit

if (isset($_POST['categoryID'])) { 
    $id = trim($_POST['categoryID']); 
    $result = array();  Labels
    $id = mysql_real_escape_string($id); 
    $res = mysql_query("SELECT * FROM subcategories WHERE category_id =  AJax
(http://www.appsntech.com/search/label/AJax) (6)
$id"); 
Angular  JS
    while ($row = mysql_fetch_array($res)) { 
(http://www.appsntech.com/search/label/Angular%20JS)
(3)  Angular  js  with  PHP
    $result[] = array(  (http://www.appsntech.com/search/label/Angular%20js%
      'id' => $row['subcatid'], 20with%20PHP)  (2)  bootstrap
      'name' => $row['description']  (http://www.appsntech.com/search/label/bootstrap)  (3)
    );  Cache  (http://www.appsntech.com/search/label/Cache)
(2)  Codeigniter
    }  (http://www.appsntech.com/search/label/Codeigni
ter)  (5)  Composer  PHP
    echo json_encode($result); 
(http://www.appsntech.com/search/label/Composer%20
}  PHP)  (2)  cross  site  scripting
(http://www.appsntech.com/search/label/cross%20site%20scrip
ting)  (1)  CRUD
(http://www.appsntech.com/search/label/CRUD)  (2)
    Cygnite  Framework
(http://www.appsntech.com/search/label/C
ygnite%20Framework)  (9)  Cygnite  PHP
Framework
(http://www.appsntech.com/search/label/Cygnite%20PHP%20F

Recomendado para você ramework)  (1)  design  patterns


(http://www.appsntech.com/search/label/design%20patterns)
things­you­should­know­
2%26at_pos%3D0%26a
(//m.addthis.com/live/re
ww.appsntech.com%2F
t_tot%3D5&uid=578303
wp&per=undefined&pco
2015%2F04%2F5­best­
520fc14567831b78&rev
url=http%3A%2F%2Fw
1.0%26at_si%3D57830
php.html%23at_pco%3
320f809d099%26at_ab
204d1e547e&pub=ra­
=smlrebh­1.0)
Dsmlrebh­
%3Dper­
=v7.2.4­
direct/?
about­ 2015%2F04%2Fbuilding
2%26at_pos%3D1%26a
(//m.addthis.com/live/re
ww.appsntech.com%2F
t_tot%3D5&uid=578303
wp&per=undefined&pco
520fc14567831b78&rev
url=http%3A%2F%2Fw
1.0%26at_si%3D57830
app.html%23at_pco%3
320f809d099%26at_ab
20cbf9c05a&pub=ra­
­simple­product­
=smlrebh­1.0)
management­
Dsmlrebh­
%3Dper­
=v7.2.4­
direct/? 2%26at_pos%3D2%26a
(//m.addthis.com/live/re
ww.appsntech.com%2F
t_tot%3D5&uid=578303
wp&per=undefined&pco
520fc14567831b78&rev
url=http%3A%2F%2Fw
1.0%26at_si%3D57830
2014%2F11%2Ffacebo
php.html%23at_pco%3
ok­style­autocomplete­
320f809d099%26at_ab
2097c4c1cc&pub=ra­
using­angular­js­
=smlrebh­1.0)
Dsmlrebh­
%3Dper­
=v7.2.4­
direct/? (1)  Drupal  (http://www.appsntech.com/search/label/Drupal)  (1)
e­commerce  (http://www.appsntech.com/search/label/e­
commerce)  (1)  facebook
(http://www.appsntech.com/search/label/facebook
)  (5)  Framwork
(http://www.appsntech.com/search/label/Framwork)  (1)  google
(http://www.appsntech.com/search/label/google)  (2)
Jquery
(http://www.appsntech.com/search/label/J
query)  (10)  Json
(http://www.appsntech.com/search/label/Json)  (2)
5 Best Things You Should Building A Simple Facebook Style
Laravel  (http://www.appsntech.com/search/label/Laravel)  (1)
Know About PHP 7 Product Management A... Autocomplete Using An...
Magento
(//m.addthis.com/live/redir
www.appsntech.com
(//m.addthis.com/live/redir
www.appsntech.com
(//m.addthis.com/live/redir
www.appsntech.com (http://www.appsntech.com/search/label/Magento
AddThis (//www.addthis.com/website­tools/overview?
)  (4)  memcached
(http://www.appsntech.com/search/label/memcached)  (1)
utm_source=AddThis%20Tools&utm_medium=image&utm_campaign=Recommended%20content%20logo)
MongoDB  (http://www.appsntech.com/search/label/MongoDB)

Posted by Sanjoy Dey (https://plus.google.com/116679848208147953128)  (1)  Mysql


Labels: AJax (http://www.appsntech.com/search/label/AJax), Jquery (http://www.appsntech.com/search/label/Jquery),
(http://www.appsntech.com/search/label/Mysql)
(5)  nusoap
Json (http://www.appsntech.com/search/label/Json), PHP (http://www.appsntech.com/search/label/PHP)
(http://www.appsntech.com/search/label/nusoap)  (2)
object  oriented  programming
(http://www.appsntech.com/search/label/object%20orien
You May Also Like ted%20programming)  (2)  pdf
Powered by SumoMe (https://sumome.com/?src=sm-dc- You might also like
(http://www.appsntech.com/search/label/pdf)  (2)

5bb6ade1e91e3cc1ee19c15918b93fc707831961821664f77b5d2fd402739f1d) PHP
Pay 1 cent per new visitor to your site
http://www.appsntech.com/2012/02/how­to­populate­datas­into­select­using.html 2/4
11/07/2016 How to populate datas into a select box using jQuery ajax json, php
Pay 1 cent per new visitor to your site
(http://www.appsntech.com/sea
Best fraud detection in pay per click advertising + low bid prices = higher
rch/label/PHP) 
engines. Your solution to the Internet...(30)  PHP  Framworks
(http://www.appsntech.com/search/label/PHP%20
www.payperranking.com
Framworks)  (7)  PHP7
(http://www.appsntech.com/search/label/PHP7)  (1)  psr­0
(http://www.appsntech.com/search/label/psr­0)  (1)  REST
webservice
(http://www.appsntech.com/search/label/REST%20webservice)
(1)  SOAP
Top 10 AngularJS Gra⩜⌷x Artist - Commonly Asked The Hottest Local (http://www.appsntech.com/search/label/SOAP)  (2)
Template Projects Android Design & JavaScript Singles Who Will ubuntu  (http://www.appsntech.com/search/label/ubuntu)
(Seeds) with Dev Blog Interview Drive You Crazy ... (3)  web  application
(http://www.appsntech.com/search/label/web%20applica
Demos Gra⩜⌷x Artist Questions and Featured in the media tion)  (2)  web  design
AngularJS 4U Answers
UI Tricks | UI (http://www.appsntech.com/search/label/web%20design
)  (3)  wordpress
(http://www.appsntech.com/search/label/wordpress)  (1)  Yii
(http://www.appsntech.com/search/label/Yii)  (1)  Zend
(http://www.appsntech.com/search/label/Zend) (2)

Building Mobile Apps?

ElixirDose Jobs Free: Learn Swift Win your FREE DIY electronics,
ElixirDose Jobs 2.2 in 30 days - Kindle Paperwhite Howtos
Apoorv Mote worth $119.99! www.devacron.com
Apoorv Mote http://www.weberbo...

Posts Archive

7 comments
►  2015 (http://www.appsntech.com/search?
updated­min=2015­01­
01T00:00:00%2B05:30&updated­max=2016­
01­01T00:00:00%2B05:30&max­results=15)
(15)
Add a comment as Alexandre Sayegh
►  2014 (http://www.appsntech.com/search?
updated­min=2014­01­
01T00:00:00%2B05:30&updated­max=2015­
01­01T00:00:00%2B05:30&max­results=22)
(22)
►  2013 (http://www.appsntech.com/search?
Top comments updated­min=2013­01­
  01T00:00:00%2B05:30&updated­max=2014­
01­01T00:00:00%2B05:30&max­results=6) (6)
▼  2012 (http://www.appsntech.com/search?
Panagiotis Roditakis 1 year ago  -  Shared publicly updated­min=2012­01­
01T00:00:00%2B05:30&updated­max=2013­
 These underscores in php always bring me a headache :-) 01­01T00:00:00%2B05:30&max­results=14)
(14)
1  ·  Reply
►  December
(http://www.appsntech.com/2012_12_01_ar
chive.html) (1)

Stanley Homer 9 months ago  -  Shared publicly ►  November


(http://www.appsntech.com/2012_11_01_ar
 You have saved my life from lot of headache! Thanks. chive.html) (1)

1  ·  Reply ►  October


(http://www.appsntech.com/2012_10_01_ar
chive.html) (1)
Sanjoy Dey 9 months ago
►  August
 Welcome!! +Stanley Homer  (http://www.appsntech.com/2012_08_01_ar
chive.html) (1)
►  May
Ingrid Sedé 1 year ago  -  Shared publicly (http://www.appsntech.com/2012_05_01_ar
chive.html) (2)
 The comma after $row['description'], shouldn't be there. ;) 
►  March
(http://www.appsntech.com/2012_03_01_ar
Thanks for keeping me busy. :P chive.html) (4)

1  ·  Reply
▼  February
(http://www.appsntech.com/2012_02_01_ar
chive.html) (4)
Sanjoy Dey 1 year ago How to use memcached with PHP ?
 You welcome. Happy coding... :) (http://www.appsntech.com/2012/02/how­
to­use­memcached­with­php.html)
How to Install Memcached in Windows 7 /
WAMP ?
Maria Antonietta Usai 3 years ago (http://www.appsntech.com/2012/02/how­
 Thanks a loto for this script! It was what I' was looking for! to­install­memcached­in­windows­
7.html)
Which Framework to use Zend or
Codeigniter ??
Sanjoy Dey 3 years ago (http://www.appsntech.com/2012/02/whic
 Most welcome Maria..... Keep visiting for new posts here.... h­framework­to­use­zend­or.html)
How to populate datas into a select box
using jQue...
(http://www.appsntech.com/2012/02/how­

http://www.appsntech.com/2012/02/how­to­populate­datas­into­select­using.html 3/4
11/07/2016 How to populate datas into a select box using jQuery ajax json, php
Newer Post (http://www.appsntech.com/2012/02/which­framework­to­use­zend­or.html) Home to­populate­datas­into­select­using.html)
Older Post (http://www.appsntech.com/2011/08/how­to­export­data­grid­datas­to­excel.html)
(http://www.appsntech.com/) ►  2011 (http://www.appsntech.com/search?
updated­min=2011­01­
Subscribe to: Post Comments (Atom) 01T00:00:00%2B05:30&updated­max=2012­
(http://www.appsntech.com/feeds/7668019231326930651/comments/default) 01­01T00:00:00%2B05:30&max­results=1) (1)

Demo Alexa Rank Apps Outlook Url Ajax Application Development


Database Designing Database Designs Datas Demo Alexa Rank Apps Outlook Followers

Join this site
with Google Friend Connect

Members (16)

Already a member? Sign in

Alexa Rank

(http://www.alexa.com/
data/details/main?
url=http://www.appsnte
ch.com/)
(http://www.alexa.com/
siteinfo/http://www.app
sntech.com/)

Follow Us On Facebook  (http://www.facebook.com/appsntech) Twitter  (https://twitter.com/appsntech) Google+

 (https://www.google.com/+Appsntech) Linkedin  (http://www.linkedin.com/groups/Open­source­Web­Developers­Programmers­4300612/about)

HOME (HTTP://WWW.APPSNTECH.COM/) PHP (HTTP://WWW.APPSNTECH.COM/P/PHP.HTML)
JQUERY (HTTP://WWW.APPSNTECH.COM/P/JQUERY.HTML) FACEBOOK (HTTP://WWW.APPSNTECH.COM/P/FACEBOOK­TUTORIAL.HTML)
CYGNITE PHP FRAMEWORK (HTTP://WWW.CYGNITEFRAMEWORK.COM/2013/08/CONTRIBUTION­TO­CYGNITE­FRAMEWORK.HTML)
ABOUT (HTTP://WWW.APPSNTECH.COM/P/ABOUT­ME.HTML) ADVERTISE WITH US (HTTP://WWW.APPSNTECH.COM/P/ADVERTISE­WITH­US.HTML)
PRIVACY POLICY (HTTP://WWW.APPSNTECH.COM/P/PRIVACY­POLICY.HTML)

COPYRIGHT @2011­2015 APPSNTECH.COM. ALL RIGHTS RESERVED. POWERED BY­ SANJOY DEY PRODUCTIONS

http://www.appsntech.com/2012/02/how­to­populate­datas­into­select­using.html 4/4

S-ar putea să vă placă și