JavaScript - Javascript function called from php does not execute

 
Vista:
sin imagen de perfil
Val: 6
Ha aumentado su posición en 14 puestos en JavaScript (en relación al último mes)
Gráfica de JavaScript

Javascript function called from php does not execute

Publicado por José (4 intervenciones) el 30/08/2022 17:48:41
I am correcting some bugs in a web page that uses php and javascript, which is hosted on a debian machine and was working correctly before, but when migrating to the latest version of debian, some screens are not working.

Specifically, in one of the screens that do not work correctly, this "php" is executed:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<link href="style1.css" rel="stylesheet" type="text/css" />
<?php
	Yii::app()->clientScript->registerCoreScript('jquery');
	Yii::app()->clientScript->registerCoreScript('jquery.ui');
 
  // Sets the value of: $var1, $var2, $var3, $var4, $var5, $var6 and $var7
?>
 
<script type="text/javascript" >
	jsonVar = eval(<?php echo $var2;?>);
	$(document).ready(function() {
		function1('<?php echo var1; ?>',
						  '<?php echo $var7; ?>',
						  '<?php echo $var3; ?>',
						  '<?php echo $var4; ?>',
						  '<?php echo $var5; ?>',
						  '<?php echo $var6; ?>',
						  jsonVar );
	});
</script>
 
<div id="content" >
	<form method="post">
		<table class="ptable" >
				<tr class="prow"  >
					<th class="ptable1" colspan="3" ><?php echo "$this->title"; ?></th>
				</tr>
 
				<tr class="prow" >
					<td class="ptable2" ><?php echo "$this->InfoName1"; ?></td>
					<td class="ptable2" ><?php echo "$this->InfoName2"; ?></td>
				</tr>
 
				<tr class="prow" >
					<td class="pinfo" id="p1" >INFO 1</td>
					<td class="pcell1" id="col1-p1" ></td>
					<td class="pcell1" id="col2-p1" >Default ...</td>
				</tr>
 
				<tr class="prow" >
					<td class="pinfo" id="p2" >INFO 2</td>
					<td class="pcell1" id="col1-p2" ></td>
					<td class="pcell1" id="col2-p2" >Default ...</td>
				</tr>
 
        // . . .
 
		</table>
	</form>
</div>
</div>

Although I do not have much knowledge about php and javascript, in view of the source code of this php, I understand that during the load of the same the call to the function function1 should be executed

The code for this function is found in the file js/tabInfo.js

I have added at the beginning of it the line of code
1
debugger;
being that way:


1
2
3
4
5
6
7
8
window.function1 = function (parameter1, parameter2, parameter3, parameter4,
										          parameter5, parameter6, parameter7 )
	{
    debugger;
 
    // Rest of function code.
    // . . .
	};

If we now open the Firebug “Debugger” tab, when the web browser enters the code of said function, the execution will stop and a step-by-step execution will be possible, checking the value of variables and what flow the execution follows.

However, when I load the page with the “Debugger” tab open, as I mentioned, I verify that the browser is not actually entering the code of this function.


I have tried to modify the source code of the php leaving it in this form:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<link href="style1.css" rel="stylesheet" type="text/css" />
<?php
	Yii::app()->clientScript->registerCoreScript('jquery');
	Yii::app()->clientScript->registerCoreScript('jquery.ui');
 
  // Sets the value of: $var1, $var2, $var3, $var4, $var5, $var6 and $var7
 
echo "<script type='text/javascript' >
	jsonVar = eval(<?php echo $var2;?>);
	$(document).ready(function() {
		function1('<?php echo var1; ?>',
						  '<?php echo $var7; ?>',
						  '<?php echo $var3; ?>',
						  '<?php echo $var4; ?>',
						  '<?php echo $var5; ?>',
						  '<?php echo $var6; ?>',
						  jsonVar );
	});
</script>";
 
?>
 
// . . .

However, the code execution of function1 still does not appear in Firebug.

Any comment or help is appreciated.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Alejandro
Val: 1.448
Plata
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

Javascript function called from php does not execute

Publicado por Alejandro (532 intervenciones) el 31/08/2022 16:05:26
  • Alejandro se encuentra ahora conectado en el
  • chat de PHP
View the console for looking errors.

I can't see the reference to your js file
1
<script type="text/javascript" src="js/tabInfo.js"></script>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar