Welcome Guest, Not a member yet? Register   Sign In
Need Help on Ajax
#6

[eluser]Nutan Lade[/eluser]
Sorry I forgoted to write the code for getObject.It is nothing but it checks the browser type and returns the msg.

function getObject(name) {
var ns4 = (document.layers) ? true : false;
var w3c = (document.getElementById) ? true : false;
var ie4 = (document.all) ? true : false;

if (ns4) return eval('document.' + name);
if (w3c) return document.getElementById(name);
if (ie4) return eval('document.all.' + name);
return false;
}



I just changed the code and used framework.

function ajaxSearchMovie(){
new Ajax.Request('/gadgets/searchMovie/a',
{
method:'get',
onSuccess: function(transport){
var response = transport.responseText || "no response text";
alert("Success! \n\n" + response);
},
onFailure: function(){ alert('Something went wrong...') }
});
}

<body>
<table>
<tr>
<td>&lt;input type="text" id="movieSearch" name="movieSearch" &gt;&lt;/td>
</tr>
<tr>
<td><div align="center" id="searchResult" name="searchResult" style="font-family:Arial; font-size:12px; width:150px; border:#000000 solid 1px; “></div></td>
</tr>
</table>

&lt;/body&gt;




gadgets.php
----------------------------------------------------------------------------------
class Gadgets extends Controller {


function Gadgets()
{
parent::Controller();
$this->load->helper('ajax');
}

function searchMovie(){

$results = “”;
$pat = $this->uri->segment(3);

$query = $this->db->query("SELECT * FROM movies_list WHERE movie_name LIKE ‘$pat%’ LIMIT 10");

foreach ($query->result() as $row)
{
$results = $results."<b>$row->movie_name</b><br />”;
}
return $results;

}

}

the above code is the code used in controller gadgets.php

these is the javascript code I used in gadgets_view.php file.

But I am getting the message "Something went wrong....."

Is that the controller is not writing any data back.If so where could be the problem.Please help me.Thanq in advance.


Messages In This Thread
Need Help on Ajax - by El Forum - 08-10-2008, 11:39 AM
Need Help on Ajax - by El Forum - 08-10-2008, 12:13 PM
Need Help on Ajax - by El Forum - 08-10-2008, 12:23 PM
Need Help on Ajax - by El Forum - 08-10-2008, 12:37 PM
Need Help on Ajax - by El Forum - 08-10-2008, 12:41 PM
Need Help on Ajax - by El Forum - 08-10-2008, 12:59 PM
Need Help on Ajax - by El Forum - 08-10-2008, 01:45 PM
Need Help on Ajax - by El Forum - 08-11-2008, 12:16 PM
Need Help on Ajax - by El Forum - 08-11-2008, 12:21 PM
Need Help on Ajax - by El Forum - 08-11-2008, 12:27 PM
Need Help on Ajax - by El Forum - 08-11-2008, 12:54 PM
Need Help on Ajax - by El Forum - 08-11-2008, 01:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB