Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript not populating Perl Form on Dev Server
    primarykey
    data
    text
    <p>I am still a newbie to Perl and have run into difficulties.</p> <p>I have a system here which needs users to be assigned permissions in order for them to run reports. </p> <p>The system is fully functional on the local test environment hosted on a machine, but once it was uploaded to the Windows Server 2008 for dev, it doesnt seem to populate the assigned reports form anymore.</p> <p>We use Javascript functions to populate the user dropdown lists and also to populate the available reports which works. When it comes to assigned reports nothing is populating anymore. The exact same code taken from the depository will work on the Local Environment with no problems.</p> <p>The assigned reports will only populate if we change the directory of the Perl script to point towards the local machine environment, instead of to the Perl script thats on the server.</p> <p>This is it pointed towards the Server Directory:</p> <pre><code>function ReadUserPermission( iUserID ) { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); var szURL; var iPermNumber = 0; szURL = "/Scripts/Security/ReadPermissions.pl"; xmlhttp.Open("POST", szURL, false); xmlhttp.Send( iUserID ); var bRetVal = PermissionTab.loadXML( xmlhttp.responseText ); var rt = xmlhttp.responseText; RGCollection = PermissionTab.XMLDocument.selectNodes("//REPORTGROUP"); for (var i=0; i&lt; RGCollection.length; i++) { RGXML = new ActiveXObject("Msxml2.DOMDocument") RGXML.loadXML( RGCollection.item(i).xml ); ReportCollection = RGXML.selectNodes( "//REPORTGROUPNAME" ); szReportGroupName = ReportCollection.item(0).text; ReportCollection = RGXML.selectNodes( "//REPORTGROUPID" ); iReportGroupID = ReportCollection.item(0).text; ReportCollection = RGXML.selectNodes( "//REPORT" ); for( var j=0; j &lt; ReportCollection.length; j++ ) { IR = new ActiveXObject( "MSXML2.DOMDocument" ); IR.loadXML( ReportCollection.item(j).xml ); IRD = IR.selectNodes( "//REPORTNAME" ); szReportName = IRD.item(0).text; IRD = IR.selectNodes( "//REPORTID" ); iReportID = IRD.item(0).text; IRD = IR.selectNodes( "//PERMISSION" ); bPermission = IRD.item(0).text; Users[iUserID].Permissions[iPermNumber] = new DataClass; Users[iUserID].Permissions[iPermNumber].ReportGroupName = szReportGroupName; Users[iUserID].Permissions[iPermNumber].ReportGroupID = iReportGroupID; Users[iUserID].Permissions[iPermNumber].ReportName = szReportName; Users[iUserID].Permissions[iPermNumber].ReportID = iReportID; Users[iUserID].Permissions[iPermNumber].Permission = bPermission; iPermNumber++; } } } </code></pre> <p>But when the szURL = "//028-07743/Scripts/Security/ReadPermissions.pl" it runs with no problems.</p> <p>Can anyone advise any help as this has baffled me.</p> <p>Here is the ReadPermissions.pl script that we think is not running.</p> <pre><code>use CGI qw/:standard *table start_ul :cgi-lib/; use Win32::ODBC; require "ServerDetails.cfg"; #Reads Details for Connection from CFG file sub ReadCfg { my $file = $_[0]; our $err; { # Put config data into a separate namespace package CFG; # Process the contents of the config file my $rc = do($file); # Check for errors if ($@) { $::err = "ERROR: Failure compiling '$file' - $@"; } elsif (! defined($rc)) { $::err = "ERROR: Failure reading '$file' - $!"; } elsif (! $rc) { $::err = "ERROR: Failure processing '$file'"; } } return ($err); } # Get our configuration information if (my $err = ReadCfg('ServerDetails.cfg')) { print(STDERR $err, "\n"); exit(1); } $szDataSource = "DSN=$CFG::CFG{'server'}{'DSN'};UID=$CFG::CFG{'server'}{'UID'};PWD=$CFG::CFG{'server'}{'PWD'}"; %PARM = Vars; $iUser = $PARM{'keywords'}; open TMP, "&gt;dhtml.txt"; $db = OpenConnection( $szDataSource ); $szSQLStatement = "EXEC spGetUserPermissionTabData '$iUser'"; $iNumRecordsRead = ReadData( -dbconnection=&gt;$db, -sqlstatement=&gt;$szSQLStatement, -datahash=&gt;\%UserData ); $szXMLString = "&lt;Permissions&gt;\n"; $szCurrentReportGroupName = ""; foreach $KEY ( sort{ $a &lt;=&gt; $b } keys %UserData ) { if( $szCurrentReportGroupName ne $UserData{$KEY}{AppGroupName} ) { if( $szCurrentReportGroupName ne "" ) #Close any previous report groups { $szXMLString .= "\t&lt;/REPORTGROUP&gt;\n"; } $szXMLString .= "\t&lt;REPORTGROUP&gt;\n" . "\t\t&lt;REPORTGROUPNAME&gt;$UserData{$KEY}{AppGroupName}&lt;/REPORTGROUPNAME&gt;\n" . "\t\t&lt;REPORTGROUPID&gt;$UserData{$KEY}{ApplicationGroupID}&lt;/REPORTGROUPID&gt;\n"; $szCurrentReportGroupName = $UserData{$KEY}{AppGroupName}; } $szXMLString .= "\t&lt;REPORT&gt;\n" . "\t\t&lt;REPORTNAME&gt;$UserData{$KEY}{AppDisplayName}&lt;/REPORTNAME&gt;\n" . "\t\t&lt;REPORTID&gt;$UserData{$KEY}{ApplicationID}&lt;/REPORTID&gt;\n" . "\t\t&lt;PERMISSION&gt;$UserData{$KEY}{PermissionType}&lt;/PERMISSION&gt;\n" . "\t&lt;/REPORT&gt;\n"; } $szXMLString .= "\t&lt;/REPORTGROUP&gt;\n" . "&lt;/Permissions&gt;"; print TMP "UserID = $szUser\n"; print TMP "XML = $szXMLString\n"; print TMP "Size of XML = " . length( $szXMLString ) . "\n"; close $TMP; print "Content-Type: text/html\n\n"; print "$szXMLString"; sub OpenConnection() { my( $szDSN ) = @_; my $db = new Win32::ODBC( $szDSN ); if( !defined $db ) { my $szLocalTime = localtime(); $szHTMLString = header; $szHTMLString .= "Error creating ODBC connection\n"; $szHTMLString .= "&lt;BR&gt;Time: $szLocalTime\n"; $szHTMLString .= end_html(); print $szHTMLString; return NULL; } return $db; } sub ReadData() { my ( %fnArgs ) = @_; my $szSQLStatement = $fnArgs{-sqlstatement}; my $cDBConnection = $fnArgs{-dbconnection}; local( *DataHash ) = $fnArgs{-datahash}; my $iRowID = 0; if ($cDBConnection-&gt;Sql($szSQLStatement)) { print "SQL failed. Error: " . $cDBConnection-&gt;Error() . "\n"; $cDBConnection-&gt;Close(); exit; } while($cDBConnection-&gt;FetchRow()) { $DataHash{$iRowID++} = {$cDBConnection-&gt;DataHash()}; } return $iRowID; } sub XMLizer { local ( *DataHash ) = @_; my $szXMLString = ""; foreach $KEY ( keys %DataHash ) { $szXMLString .= "\t&lt;" . $KEY . "&gt;" . $DataHash{$KEY} . "&lt;/" . $KEY . "&gt;\n"; } return $szXMLString; } </code></pre> <p>It now looks like if we change the SQL statement in the Perl file to <code>$szSQLStatement = "EXEC spGetUserPermissionTabData 464";</code> it will populate the assigned window with that specific users reports, even if that user is not select(expected). we now think that maybe the Perl file isnt recieving the iUserID that the Javascript is sending to it</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload