Ajax quistion |
[eluser]Markie577[/eluser]
Hi good people of codeigniter! I have a ajax related problem. I want to send a variable to a different page! but I can't seem to load the other page! Could someone help me? This is the code Code: <?php And this is the page that should receive it Code: <?php
[eluser]Flemming[/eluser]
whatever you're trying to do with AJAX, you will find it much much easier with jQuery! search the web for examples and tutorials - there are plenty (e.g. http://www.ibm.com/developerworks/librar...query.html) and forget they way you are trying to do things currently!
[eluser]Markie577[/eluser]
[quote author="Flemming" date="1275586313"]whatever you're trying to do with AJAX, you will find it much much easier with jQuery! search the web for examples and tutorials - there are plenty (e.g. http://www.ibm.com/developerworks/librar...query.html) and forget they way you are trying to do things currently! [/quote] Well it was asked to do it in ajax! I'll look into jquery, but I need to do this in ajax!
[eluser]Flemming[/eluser]
jQuery will help you simplify the ajax! http://api.jquery.com/category/ajax/ :-)
[eluser]Markie577[/eluser]
[quote author="Flemming" date="1275586747"]jQuery will help you simplify the ajax! http://api.jquery.com/category/ajax/ :-)[/quote] Yeah i see what you mean! BUT!! this is probably more of a codeigniter(php) problem than a bad ajax script :-)
[eluser]Flemming[/eluser]
Quote:this is probably more of a codeigniter(php) problem than a bad ajax script maybe! Quote:but I can’t seem to load the other page! what exactly are you trying to achieve? If you can explain it, maybe someone can suggest a simplified way to achieve it. Personally, I don't do any AJAX without jQuery any more - there's no point. So I can't debug your existing code, I could only suggest a neater way to do it ... if I understood exactly what you want to do!
[eluser]Markie577[/eluser]
[quote author="Flemming" date="1275588043"]maybe! Quote:but I can’t seem to load the other page! what exactly are you trying to achieve? If you can explain it, maybe someone can suggest a simplified way to achieve it. Personally, I don't do any AJAX without jQuery any more - there's no point. So I can't debug your existing code, I could only suggest a neater and way to do it ... if I understood exactly what you want to do![/quote] Basically check the value of 1 checkbox and then fill the second checkbox with appropiate data Example USA = Washinton, New-York, Lon Angeles India= Napu , Mumbai
[eluser]Flemming[/eluser]
Quote:Basically check the value of 1 checkbox and then fill the second checkbox with appropiate data ok! with jQuery this will be very easy! download jquery : http://code.jquery.com/jquery-1.4.2.min.js and save it wherever you save your other js create a method in your controller like this: Code: function cities($country) try that method out by visiting it with your brower : yoursite.com/your_controller/cities/USA to make sure it doesn't error (none of this code is actually tested!) Now in the view that contains the country selector: load the jquery library Code: <s c r 1 p t type="text/javascript" src="your_path/js/jquery-1.4.2.min.js"></s c r 1 p t> you can refer to your country select by ID or class. Let's use ID: Code: <select name="country" id="country"> now in the head of your view that contains the country select, do the jquery magic! Code: <s c r 1 p t type="text/javascript"> so when you change the select with an ID of 'country', your jQuery script will make the ajax call to the specified url (/your_controller/cities/country) and receive the output of that method and insert it into the empty div with an ID of 'cities_list' Like I said, i havent tested this code, it MAY have bugs! (sorry) I hope it helps you though, see how beautiful AJAX is in codeigniter with jQuery! |
Welcome Guest, Not a member yet? Register Sign In |