Reputation: 12512
I am trying to figure out how o combine jQuery code, where I grab a URL value from a field a PHP code that will hit that URL to check if the site exists... I have to use the jQuery in this case. Perhaps i can validate the URL with it too?..
$("#go").click(function() {
var $url = $("#url").val();
<?php
$x = @fopen($url,"r");
if ($x) {
?>
$("#ws").attr("src",url);
$("#start").remove();
<?php
fclose($x);
} else {
?>
alert("bad URL");
<?php
}
?>
});
Upvotes: 0
Views: 81
Reputation: 33865
You are mixing client- and server-side languages. PHP is run on the server, before the page is served to the client. JavaScript (thus jQuery) does usually run on the client. Due to this, it doesn't make sense to mix the languages like in your example. You will have to separate them, using JavaScript on the client, making request to server. On the server you can then use PHP.
Step-by-step what you need to do:
Upvotes: 3