/    Sign up×
Community /Pin to ProfileBookmark

how to call php file using external javascript

the error i am getting in the html file
Message: Syntax error
Line: 1
Char: 1
Code: 0
URI: [url]http://localhost/testhtml/test.php[/url]
The test.php code is
<?php
Header(“content-type: application/x-javascript”);
echo “document.write(‘Hello World I am php code called from HTML file:’);”;
CLOSE WINDOW;
?>

The test.html code is
“<script language=”JavaScript” type=”text/javascript” src=”http://localhost/testhtml/test.php”></script>”
HELLO TESTING

i have enclosed external javascript call within single quote so that it gets displayed here
hello testing is within h1 tags of html
Can anyone help me in resolving this. I am new to php

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@dk_zero-coolJun 27.2010 — Well, you could start by removing the line "CLOSE WINDOW;" that has nothing to do with php, or any other languages.
Copy linkTweet thisAlerts:
@pankaj87us_gmaiauthorJun 28.2010 — thank you so much for your responses.

As i said i am new to php.

My requirement is simple.

I have a contact us page along with other pages all designed in html. I am validating all fields of contact us page using javascript. If values are in correct format i am calling the php file for sending mails.

My js script is working perfectly. the only thing i need to learn is how to call and execute that php file from javascript so that i can send mails.

Your help is highly appreciated.

Pankaj
Copy linkTweet thisAlerts:
@MindzaiJun 28.2010 — You also appear to be using non-standard single and double quotes - are you using word or something similar to write this code? You need to use a plain text editor rather than a word processor to write source code.
×

Success!

Help @pankaj87us_gmai spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...