Ciao a tutti,
premetto che mi sto affacciando da poco ad Ajax/Jquery (perdonerete la mia ignoranza in merito...) ho questo problema:
In un articolo richiamo un file php che utilizzo normalmente per creare dei dati custom.
Quindi nell'articolo inserisco il codice
{script}
<?php include "file_include/pagina.php"; ?>
{/script}
e finqui, nessun problema.
Ora, in questa pagina ho la necessità di inserire un campo di input text con un autocompleter che legge i dati dal db.
quindi:
<html>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#name").autocomplete({
source:'file_include/scrivania_dipendente/script-autocompl.php',
minLength:1
});
});
</script>
</head>
<body>
<form method="post" action="">
Name : <input type="text" id="name" name="name" />
</form>
</body>
<html>
Il file php per l'autocomplete è il seguente:
<?php
mysql_connect("localhost","root","password");
mysql_select_db("db_intra_new");
$term=$_GET["term"];
$query=mysql_query("SELECT * FROM xcsri_anagrafica_generale where nominativo like '%".$term."%' order by cognome ");
$json=array();
while($student=mysql_fetch_array($query)){
$json[]=array(
'value'=> $student["nominativo"],
'label'=>$student["nominativo"]." - ".$student["id"]
);
}
echo json_encode($json);
?>
Purtroppo, non funziona.
Ho provato a "girare" il codice in una pagina esterna a Joomla (quindi senza caricare il core) e funziona...
Qualcuno riesce a spiegarmi il perché?
Ho pensato ad un conflitto Jquery ma non riesco a capire....
Di seguito la sorgente della pagina
<!DOCTYPE html>
<html lang="it-IT" dir="ltr">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8" />
<base href="http://10.39.254.227/index.php/scrivania-lavoratore" />
<meta name="author" content="Andrea Suriani" />
<meta name="generator" content="Joomla! - Open Source Content Management" />
<title>Intranet Coop - SCRIVANIA LAVORATORE</title>
<link href="http://10.39.254.227/plugins/content/pdf_embed/assets/css/style.css" rel="stylesheet" />
<link href="http://10.39.254.227/modules/mod_datetime/tmpl/default.css" rel="stylesheet" />
<link href="/media/system/css/frontediting.css?aad77d13e0df51e2079cf1e04c6378a6" rel="stylesheet" />
<link href="http://10.39.254.227/modules/mod_bm_slide_login/assets/css/styles.css" rel="stylesheet" />
<link href="/templates/it_milano/uikit/css/uikit.min.css" rel="stylesheet" />
<link href="/media/gantry5/assets/css/font-awesome.min.css?5a33dc1b" rel="stylesheet" />
<link href="/media/gantry5/engines/nucleus/css-compiled/nucleus.css?5a33dc1c" rel="stylesheet" />
<link href="/templates/it_milano/custom/css-compiled/milano_15.css?5a33ddef" rel="stylesheet" />
<link href="/media/gantry5/assets/css/bootstrap-gantry.css?5a33dc1b" rel="stylesheet" />
<link href="/media/gantry5/engines/nucleus/css-compiled/joomla.css?5a33dc1c" rel="stylesheet" />
<link href="/media/jui/css/icomoon.css" rel="stylesheet" />
<link href="/templates/it_milano/custom/css-compiled/milano-joomla_15.css?5a33ddf0" rel="stylesheet" />
<link href="/templates/it_milano/custom/css-compiled/custom_15.css?5a33ddf0" rel="stylesheet" />
<link href="/templates/it_milano/custom/csri_css.css?5a3a7988" rel="stylesheet" />
<style>
@media (min-width: 48rem) {
.g-offcanvas-toggle {
display: none;
}
}
</style>
<script type="application/json" class="joomla-script-options new">{"csrf.token":"ff666fd79e602f3c349b1ac97fcc02f0","system.paths":{"root":"","base":""},"system.keepalive":{"interval":840000,"uri":"\/index.php\/component\/ajax\/?format=json"}}</script>
<script src="/media/jui/js/jquery.min.js?aad77d13e0df51e2079cf1e04c6378a6"></script>
<script src="/media/jui/js/jquery-noconflict.js?aad77d13e0df51e2079cf1e04c6378a6"></script>
<script src="/media/jui/js/jquery-migrate.min.js?aad77d13e0df51e2079cf1e04c6378a6"></script>
<script src="/media/system/js/caption.js?aad77d13e0df51e2079cf1e04c6378a6"></script>
<script src="/media/jui/js/bootstrap.min.js?aad77d13e0df51e2079cf1e04c6378a6"></script>
<script src="/media/system/js/core.js?aad77d13e0df51e2079cf1e04c6378a6"></script>
<script src="/media/system/js/frontediting.js?aad77d13e0df51e2079cf1e04c6378a6"></script>
<script src="http://10.39.254.227/modules/mod_bm_slide_login/assets/js/jquery.hoverIntent.minified.js"></script>
<!--[if lt IE 9]><script src="/media/system/js/polyfill.event.js?aad77d13e0df51e2079cf1e04c6378a6"></script><![endif]-->
<script src="/media/system/js/keepalive.js?aad77d13e0df51e2079cf1e04c6378a6"></script>
<script>
jQuery(window).on('load', function() {
new JCaption('img.caption');
});
jQuery(function($){ $(".hasTooltip").tooltip({"html": true,"container": "body"}); });
jQuery(function($){ $(".hasPopover").popover({"html": true,"trigger": "hover focus","container": "body"}); });
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="/plugins/content/codicefiscale/assets/css/style.css">
<!--[if (gte IE 8)&(lte IE 9)]>
<script type="text/javascript" src="/media/gantry5/assets/js/html5shiv-printshiv.min.js?5a33dc1b"></script>
<link rel="stylesheet" href="/media/gantry5/engines/nucleus/css/nucleus-ie9.css?5a33dc1c" type="text/css"/>
<script type="text/javascript" src="/media/gantry5/assets/js/matchmedia.polyfill.js?5a33dc1b"></script>
<![endif]-->
</head>
<body class="gantry site com_content view-article no-layout no-task dir-ltr itemid-431 outline-15 g-offcanvas-right g-default g-style-preset5">
<div id="g-offcanvas" data-g-offcanvas-swipe="0" data-g-offcanvas-css3="1">
<div class="g-grid">
<div class="g-block size-100">
<div id="mobile-menu-1371-particle" class="g-content g-particle"> <div id="g-mobilemenu-container" data-g-menu-breakpoint="48rem"><>
<>
<>
<>
<div class="g-grid">
<div class="g-block size-100">
<div class="g-content">
<div class="platform-content"><div class="moduletable jmoddiv" data-jmodediturl="http://10.39.254.227/index.php?option=com_config&controller=config.display.modules&id=149&Itemid=431&return=aHR0cDovLzEwLjM5LjI1NC4yMjcvaW5kZXgucGhwL3Njcml2YW5pYS1sYXZvcmF0b3Jl" data-target="_self" data-jmodtip="<strong>Modifica modulo</strong><br />workbench<br />Posizione: offcanvas-b">
<div class="custom" >
<h3><span style="color: #08c;">WORKBENCH</span></h3>
<p> <div class="moduletable">
<h3>GESTIONE CASSA</h3>
<ul class="nav menu">
<li class="item-296"><a href="/index.php/lista-stipendi" >Lista Stipendi</a></li></ul>
<>
</p>
<p> <div class="moduletable">
<h3>FILE IMPVOCO</h3>
<ul class="nav menu">
<li class="item-213"><a href="/index.php/acconti-ordinari" >Acconti Ordinari</a></li><li class="item-214"><a href="/index.php/file-extra" >File EXTRA</a></li><li class="item-215"><a href="/index.php/ore-importi-da-busta-paga" >Ore/Importi da Busta Paga</a></li></ul>
<>
</p>
<p> <div class="moduletable">
<h3>CONFIGURAZIONE</h3>
<ul class="nav menu">
<li class="item-391"><a href="/index.php/pannello-configurazione" >PANNELLO CONFIGURAZIONE</a></li></ul>
<>
</p><>
<><>
<>
<>
<>
<>
<div id="g-page-surround">
<div class="g-offcanvas-hide g-offcanvas-toggle" data-offcanvas-toggle aria-controls="g-offcanvas" aria-expanded="false"><i class="fa fa-fw fa-bars"></i><>
<section id="g-top">
<div class="g-container"> <div class="g-grid">
<div class="g-block size-70">
<div class="g-content">
<div class="platform-content"><div class="moduletable jmoddiv" data-jmodediturl="http://10.39.254.227/index.php?option=com_config&controller=config.display.modules&id=150&Itemid=431&return=aHR0cDovLzEwLjM5LjI1NC4yMjcvaW5kZXgucGhwL3Njcml2YW5pYS1sYXZvcmF0b3Jl" data-target="_self" data-jmodtip="<strong>Modifica modulo</strong><br />data_ora<br />Posizione: particle">
<div class="mod_datetime">Oggi è il <time datetime="2017-12-22T08:05:44+01:00">22/12/2017 e sono le
<span id="mod_datetime_custom_time_150"></span>
<script type="text/javascript">
<!--
zone=0
isitlocal=true;
ampm="";
function mod_datetime_custom_time_150()
{
now=new Date();
ofst="01";
ofst_minutes="00";
ofst_sign="+";
now.setUTCHours(now.getUTCHours()+Math.abs(ofst), now.getUTCMinutes()+Math.abs(ofst_minutes));
timezone = now.getTimezoneOffset();
secs=now.getUTCSeconds();
sec=-1.57+Math.PI*secs/30;
mins=now.getUTCMinutes();
min=-1.57+Math.PI*mins/30;
hr=(isitlocal)? now.getUTCHours():(now.getUTCHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24;
ampm = (hr > 11)?"":"";
statusampm = ampm;
hr2 = hr;
if (hr2 == 0) hr2=24;//24 or 12
(hr2 < 13)?hr2:hr2 %= 24;// 24 or 12
if (hr2<10) hr2="0"+hr2
var finaltime=hr2+":"+((mins < 10)?"0"+mins:mins)+":"+((secs < 10)?"0"+secs:secs)+" "+statusampm;
document.getElementById("mod_datetime_custom_time_150").innerHTML=finaltime
setTimeout("mod_datetime_custom_time_150()",1000)
}
mod_datetime_custom_time_150()
//-->
</script></time><>
<><>
<>
<>
<div class="g-block size-30">
<div class="g-content">
<div class="platform-content"><div class="moduletable jmoddiv" data-jmodediturl="http://10.39.254.227/index.php?option=com_config&controller=config.display.modules&id=87&Itemid=431&return=aHR0cDovLzEwLjM5LjI1NC4yMjcvaW5kZXgucGhwL3Njcml2YW5pYS1sYXZvcmF0b3Jl" data-target="_self" data-jmodtip="<strong>Modifica modulo</strong><br />BM LOGIN (Alto)<br />Posizione: top-d">
<div class="bm_slide_login">
<form action="/index.php/scrivania-lavoratore" method="post" id="login-form" class="form-vertical">
<div class="login-greeting">
Ciao Andrea Suriani, <>
<div class="bm_login_label" onclick="document.getElementById('login-form').submit();"><i class="icon-unlock icon-small"></i> Esci<>
<div class="bm_clear"><>
<input type="hidden" name="option" value="com_users" />
<input type="hidden" name="task" value="user.logout" />
<input type="hidden" name="return" value="aW5kZXgucGhwP0l0ZW1pZD0xMDE=" />
<input type="hidden" name="ff666fd79e602f3c349b1ac97fcc02f0" value="1" />
</form>
<>
<><>
<>
<>
<>
<>
</section>
<header id="g-header" data-uk-sticky="{media: 768}">
<div class="g-container"> <div class="g-grid">
<div class="g-block size-20">
<div id="logo-9769-particle" class="g-content g-particle"> <div class="g-logo-image" >
<a href="/" title="Milano" rel="home" class="g-logo ">
<img class="g-logo-height g-normal-logo" src="/images/logo_intranet250.png" alt="Milano" /> <img class="g-logo-height g-fixed-logo" src="/images/logo_intranet250.png" alt="Milano" /> </a>
<>
<>
<>
<div class="g-block size-75">
<div id="menu-5274-particle" class="g-content g-particle"> <nav class="g-main-nav" role="navigation" data-g-mobile-target data-g-hover-expand="true">
<ul class="g-toplevel">
<li class="g-menu-item g-menu-item-type-component g-menu-item-102 g-standard ">
<a class="g-menu-item-container" href="/index.php/scrivania">
<i class="fa fa-desktop fa-3x" aria-hidden="true"></i>
<span class="g-menu-item-content">
<span class="g-menu-item-title">SCRIVANIA</span>
</span>
</a>
</li>
<li class="g-menu-item g-menu-item-type-component g-menu-item-347 g-standard ">
<a class="g-menu-item-container" href="/index.php/elaborazione-mensile">
<i class="fa fa-edit fa-3x" aria-hidden="true"></i>
<span class="g-menu-item-content">
<span class="g-menu-item-title">ELABORAZIONE MENSILE</span>
</span>
</a>
</li>
<li class="g-menu-item g-menu-item-type-component g-menu-item-251 g-standard ">
<a class="g-menu-item-container" href="/index.php/archivio-lavoratori">
<i class="fa fa-folder-o fa-3x" aria-hidden="true"></i>
<span class="g-menu-item-content">
<span class="g-menu-item-title">ARCHIVIO LAVORATORI</span>
</span>
</a>
</li>
<li class="g-menu-item g-menu-item-type-component g-menu-item-252 g-standard ">
<a class="g-menu-item-container" href="/index.php/archivio-aziende">
<i class="fa fa-building-o fa-3x" aria-hidden="true"></i>
<span class="g-menu-item-content">
<span class="g-menu-item-title">ARCHIVIO AZIENDE</span>
</span>
</a>
</li>
<li class="g-menu-item g-menu-item-type-component g-menu-item-129 g-standard ">
<a class="g-menu-item-container" href="/index.php/documenti-condivisi">
<i class="fa fa-cloud-download fa-3x" aria-hidden="true"></i>
<span class="g-menu-item-content">
<span class="g-menu-item-title">DOCUMENTI CONDIVISI</span>
</span>
</a>
</li>
</ul>
</nav>
<>
<>
<div class="g-block size-5">
<div id="offcanvas-toggle-1784-particle" class="g-content g-particle"> <div class="offcanvas-toggle-particle g-offcanvas-toggle" data-offcanvas-toggle="">
<i class="fa fa-bars"></i>
<>
<>
<>
<>
<>
</header>
<section id="g-system-messages">
<div class="g-container"> <div class="g-grid">
<div class="g-block size-100">
<div class="g-system-messages">
<>
<>
<>
<>
</section>
<section id="g-container-main" class="g-wrapper">
<div class="g-container"> <div class="g-grid">
<div class="g-block size-100">
<section id="g-mainbody">
<div class="g-grid">
<div class="g-block size-100">
<div class="g-content">
<div class="platform-content row-fluid"><div class="span12"><article class="item item-page" itemscope itemtype="https://schema.org/Article">
<meta itemprop="inLanguage" content="it-IT" />
<div class="g-article-header">
<div class="page-header">
<h2 itemprop="name">
Scrivania Lavoratore </h2>
<>
<div class="icons">
<div class="btn-group pull-right">
<button class="btn dropdown-toggle" type="button" id="dropdownMenuButton-29" aria-label="User tools"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="icon-cog" aria-hidden="true"></span>
<span class="caret" aria-hidden="true"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton-29">
<li class="edit-icon"> <a href="/index.php/scrivania-lavoratore?task=article.edit&a_id=29&return=aHR0cDovLzEwLjM5LjI1NC4yMjcvaW5kZXgucGhwL3Njcml2YW5pYS1sYXZvcmF0b3Jl" title="Modifica articolo"> <span class="hasTooltip icon-edit tip" title="<strong>Modifica articolo</strong><br />Pubblicato<br />Lunedì, 11 Dicembre 2017<br />Scritto da Andrea Suriani"></span>
Modifica</a> </li>
</ul>
<>
<>
<>
<div itemprop="articleBody">
<p>
<html>
<head>
<script type="text/javascript"
src="/media/jui/js/jquery.min.js"></script>
<script type="text/javascript"
src="/media/jui/js/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#name").autocomplete({
source:'file_include/scrivania_dipendente/script-autocompl.php',
minLength:1
});
});
</script>
</head>
<body>
<form method="post" action="">
Name : <input type="text" id="name" name="name" />
</form>
</body>
<html>
</p> <>
</article><><>
<>
<>
<>
</section>
<>
<>
<>
</section>
<footer id="g-footer">
<div class="g-container"> <div class="g-grid">
<div class="g-block size-100">
<div id="custom-1640-particle" class="g-content g-particle"> <p>© 2016-2017 Consorzio CSRI - Tutti i diritti riservati.</p>
<>
<>
<>
<>
</footer>
<section id="g-to-top">
<div class="g-container"> <div class="g-grid">
<div class="g-block size-100">
<div id="totop-7154-particle" class="g-content g-particle"> <div class="totop g-particle">
<div class="g-totop style2">
<a href="#" id="g-totop-button" rel="nofollow" data-uk-smooth-scroll>
<i class="fa fa-angle-up"></i> </a>
<>
<>
<>
<>
<>
<>
</section>
<>
<script type="text/javascript" src="/media/gantry5/assets/js/main.js?5a33dc1b"></script>
<script type="text/javascript" src="/templates/it_milano/uikit/js/uikit.min.js"></script>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
$(window).scroll(function() {
if ($(document).scrollTop() < 500 || $(window).width() < 767) {
$('#g-totop-button').removeClass('totopfixed');
} else {
$('#g-totop-button').addClass('totopfixed');
}
});
});
})(jQuery);
</script>
<script type="text/javascript" src="/templates/it_milano/js/template.js"></script>
<script type="text/javascript" src="/templates/it_milano/js/scrollReveal.min.js"></script>
<script type="text/javascript">
window.sr = new scrollReveal({ mobile: false });
</script>
</body>
</html>
Qualsiasi suggerimento è ben accetto!!!
PS: Solitamente utilizzo Chronoforms per fare queste cose ma ora ho bisogno di farle senza componenti esterni, quindi a manina.......
PS2: Purtroppo è un Intranet, quindi non riesco a darvi un link per sbirciare...