code syntax auto interpret into html entity code - javascript

I run a php file on my server, it was fine when i edited the code locally. After I uploaded it to the server, some symbols were converted to HTML Entity Code.
Why would this happen?
I'm using Insert_PHP plugin, and the code is running within a page inside Wordpress. I created a few pages, only this is having syntax interpretation issues.

Related

Using webpack to display content in the html file from the js file

I'm new to webpack and I would like to display some content to the html file. I am also using firestore to store some data that I would like to show.
I have tried multiple ways that would work in a normal JS file and when i write the script in a separate JS file they display in the browser.
Could anyone give me any advice on where to start with this I've also tried whats written on the webpack site but that also didnt work.

Original Code Not Executing After Removing Javascript in Eclipse

I tried inserting some javascript into a jsp file on Eclipse. I added a scripts folder to the WebContent folder and added a helloWorld.js file and then added a script tag and did some input validation, which failed to work.
After removing all this failed javascript validation my original code no longer runs. I get a 500 error just trying to submit a parameter on the request. The parameter is null when I enter a number on the form. Any idea why? This is Eclipse.
I have deleted the javascript, the javascript file, and the scripts folder.
Yours Truly
(As Humanly Possible)
Cnight62

How to access a local JSON file with Javascript?

I have a Python program that generates an html page for reporting results. The html page is saved in an output directory on disk alongside a javascript file that helps with dynamic table handling. I also save a JSON file to this output directory that I would like to read in with my javascript file. This JSON file has data from the Python run (saved dictionary) that I would like to be able to access. So in an output directory on disk I have:
C:/somedirectory/output/report.html
C:/somedirectory/output/tables.js
C:/somedirectory/output/data.json
All files have been created from my program.
My html page has a table with checkboxes and if those checkboxes are selected I would like to update a second table based on data saved in the JSON file. Thus I would like to open my html report in any browser and read in the JSON file as a javascript object.
I have been trying to use ajax and .getJSON but am getting the
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
I have searched and seen many similar problems but have not come across anything that quite fits what I need. Thoughts and a work around would be greatly appreciated. Thanks.
Update
Since everything is run locally on the client side I have decided to embed the JSON data (python dictionary) and javascript code directly into the html report output. This way the data is internally accessible and the html file can be passed around without dependency issues. The user with the answer I selected below has a link that eludes to this solution.
JavaScript runs on the client machine, hence it can only access files on the client machine using a special setup.
If you want it to read JSON on your server, you should use the path:
http://example.com/output/data.json
Better way would be to read/write JSON file from Python and then send the table data to JavaScript as in this answer: Send data from Python to Javascript (JSON)

Xml to js code problem

So i'm very new to xml to javascript so i thought I would learn from w3schools, but this site
http://www.w3schools.com/xml/xml_to_html.asp shows an example that I can't mimic locally. I copy/pasted the .js and downloaded the xml but I just get a blank screen!
It's working in there try it yourself but not for me? Do I need it on a server or something?
Yes, that code retrieves the XML data from a web server using AJAX. Since you don't have a server running locally, you can change the URL to point directly to the w3school's version:
xmlhttp.open("GET","http://www.w3schools.com/xml/cd_catalog.xml",false);
Alternatively, play around on their online version ;)
well i guess you have to add the example xml (cd_catalog.xml) to your file system. and you definitively have to access the html file on a server (apache i.e.)
First, ensure that both HTML file (with the Javascript block in it) and XML file are placed in the same directory.
Next, you probably need to place those files under your local web-server and open the HTML like this:
http://[local server host]/ajax.html
instead of opening the file directly from e.g. Windows Explorer:
C:\[path to the file]\ajax.html
For the latter case you'll get an "Access is denied" error.
-- Pavel
Are you running this under a web server or just creating a couple of text files and loading them in your browser?
The "GET" request this relies upon could possibly be failing.
Use Apache or another similar HTTP server and run the example as if it were hosted on the web.

JQuery UI Click call works on local machine but not when published to server - also using CakePHP

I have some javascript that looks like this:
$('.resultitem').click(function(event){
alert('check this gets called');
location.href='viewinfo/'+$(this).attr('rel');
});
this code works fine on my local machine but after uploading to the server it doesn't seem to get called at all. Can anybody help me understand why?
UPDATE: As mentioned below this was caused by a script error higher up. While debugging with firebug, I noticed on the server that in the net tab a GET jquery.cookie.js failes with a code of 406 not acceptable.
I had to rename to jquerycookie.js to keep this particular hosting provider happy. I did a little more research and this could be due to the following:
"anything with .cookie. in it triggers an Apache mod_security warning, stopping the file from being served, effectively making this unable to work"
Are you including your JavaScript files using Cake's HTML helper? For example:
echo $this->Html->script(array('jquery-1.4.3.min'));
Note that following Cake's conventions, I've left off the .js file extension. In my experience, this has created problems where the production server thinks that .min is the file extension and attempts to load a nonexistent file called jquery-1.4.3.min, which means jQuery isn't loaded and therefore the snippet you've posted would fail.
I'm not sure if this is how you're loading your scripts, but in general it's safer to use the entire file name, like so:
echo $this->Html->script(array('jquery-1.4.3.min.js'));

Categories

Resources