[eluser]Unknown[/eluser]
I faced a problem with posting a value from field ( text.val() ) to a view page. Everything seems to be fine, console log shows the data but from the php function it doesn't show anything ( it only does if it is encrypted with sha1). If you need more details please ask, this is frustrating.
Quote: //Result in page view
//passed(post) : da39a3ee5e6b4b0d3255bfef95601890afd80709
//no sha(post) :
//console.log passed plain(post) :: PLFyUEsvfX7p-ptrJzMMrhUKTkFRI48m6b
//controller
Code:
public function importPlaylistYT($id ="PLFyUEsvfX7p-ptrJzMMrhUKTkFRI48m6b",$index = 1,$results = 2){
$ytclass = new YTClass;
//$innerdata = $ytclass->playlist_feed('PL1A3F38B724842E2C', 1, 2);
// Validate stuff
if(!is_numeric($index)) {
$ytclass->error = "playlist_feed() - Second parameter (index) must be numeric";
return false;
}
if(!is_numeric($results)) {
$ytclass->error = "playlist_feed() - Third parameter (results) must be numeric";
return false;
}
$result = $ytclass->curl_run('http://gdata.youtube.com/feeds/api/playlists/'.$id.'?start-index='.$index.'&max;-results='.$results);
if($result == false)
return false;
if(strlen($result) < 100){
$ytclass->error = 'playlist_feed() - '.$result;
return false;
}
// Start parsing with SimpleXML
$xml = simplexml_load_string($result);
// Number of results, index and results per page
$openSearch = $xml->children('openSearch', true);
$result_arr = $ytclass->open_search($openSearch);
$c = 0;
foreach($xml->entry as $entry) {
$result_arr['results'][$c] = $ytclass->parse_entry($entry);
$c++;
}
//var_dump($result_arr['totalResults']);
echo "<pre>";
var_dump($result_arr);
echo "</pre>";
$x=0;
$store=array();
//foreach($result_arr as $dataset){
// $store[] = array_push($dataset['results'][$x]);
// $x++;
//}
// $store[] = array_push($dataset['results'][$x]);
//var_dump($store);
//echo 'http://gdata.youtube.com/feeds/api/playlists/'.$id.'?start-index='.$index.'&max;-results='.$results;
$password1 = sha1($this->input->post("yt_id",TRUE));
$password2 = $this->input->post("yt_id");
echo "passed : " .$password1 ."</br>";
echo "no sha :" .$password2;
//Result in page view
//passed(post) : da39a3ee5e6b4b0d3255bfef95601890afd80709
//no sha(post) :
//console.log passed plain(post) :: PLFyUEsvfX7p-ptrJzMMrhUKTkFRI48m6b
//$this->input->post("yt_id")
//js $.post('music/importPlaylistYT', {"yt_id": ytpllink}, function(data, textStatus)
//can you do all this for 10? ill make it easy for you and might get more tasks
$this->load->view('ajax/importPlaylistYT',$data);
}
//js handler
Code:
function importPlaylistYT()
{
var ytpllink = $('#getYTlink [name="yt_id"]').val();
//if(isEmpty(ytpllink))
//{
// alert(msg_required_fields);
// return false;
//}
$.post('music/importPlaylistYT', {"yt_id": ytpllink}, function(data, textStatus) {
alert( "success" );
})
.done(function() {
alert( "second success" + ytpllink);
console.log("passed on js : " + ytpllink);
$("#YTImporterModal").modal("hide");
show_loading();
$.get(base_url+"music/importPlaylistYT/", function(data, textStatus) {
$("#target").html(data);
});
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "finished" );
});
}
function importPlaylistYT_modal()
{
$("#YTImporterModal").modal("show");
}
//main frame view music.php
Code:
@MODAL
<div class="modal" id="YTImporterModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"><?php echo ___("label_change_password"); ?></h4>
</div>
<div class="modal-body loginModal">
<form class="form-signin" role="form">
<div id="getYTlink">
<h3 class="form-signin-heading"><?php echo ___("label_change_password"); ?></h3>
<input type="text" name="yt_id" class="form-control" placeholder="Give PL id" required>
<button class="btn btn-primary" type="button"><?php echo ___("label_change_password_button"); ?></button>
</div>
<div class="clearfix"></div>
</form>
</div>
</div>
</div>
</div>
@
LinK for modal popup
Code:
<li id="importPlaylistYT">
<a href="#" >F</a>
</li>
//page view importPlaylistYT.php
Code:
<div class="row">
<div class="jumbotron" id="">
<h1></h1>
<h3><strong></strong></h3>
<p></p>
</div>
</div>
<?PHP
if(count($importPlaylistYT->data) == 0)
{
?>
<div class="alert alert-info">
<strong><?php echo $query ?></strong> No Found!
</div>
<?php
}
?>