ajax, JavaScript, jquery, Uncategorized

returning value from jquery ajax api


.responseText is used to return the value with ajax api

check_title_exist : function(_title){

return $.ajax({
url: base_url+”themes/theme_title_exist/”,
data:{title:_title},
cache: false,
type:’POST’,
async: false
}).responseText;
}

//php part

function theme_title_exist(){
$title = $this->input->post(‘title’, TRUE);
if($this->themes_model->check_theme_title_exit($title)):
echo ‘true’;
else:
echo ‘false’;
endif;
}

/// java script view part

res = themes_mod.check_title_exist(ni_gui.get_value(_post_data,’title’));

if(res == ‘true’){
alert(1)
}else{
alert(0)
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s