I’m currently trying to get my head around the jQuery language. I’m trying to make sort of a RSS validator. The idea is that the user types in RSS URL and then the jQuery checks if the RSS has an title. If it does it sends it to a PHP file which checks if it already exists in the database and then sends back the results to the original page. All without refreshing.
I can make it work so the jQuery sends the information to the php which checks if it exists and then sends the result back without refreshing.
The problem comes up when I try to implement the RSS jQuery function. I have tried to simply put it in the other jQuery but it just refreshes.
The form:
<form id="lets_add" action="" method="get">
<input id="addurl" type="text" name="URL" value="URL"onfocus="searchinput();" onblur="searchinput2();" />
The jQuery code to pass it to the php, without the title:
$(function() {
$("#lets_add").bind('submit', function(){
var value = $('#addurl').val();
$.post('db_add.php',{value:value}, function(data){
$("#val_add").html(data);
});
return false;
});
});
The php:
mysql_select_db ("members");
$term = mysql_real_escape_string(@$_POST['value']);
$title = mysql_real_escpae_string(@$_POST['title']);
$ost = "SELECT * FROM linkdb WHERE URL = '$term' OR name = '$title'";
if(mysql_num_rows(mysql_query($ost))){
echo "The RSS exists in the database.";
}
else{
echo "The RSS i validated, with title: " . $title;
}
mysql_close($con);
And the RSS title:
$.get('proxy.php?url='+$('#addurl').val(), function(d) {
//find each 'item' in the file and parse it
$(d).find('channel').each(function() {
var $channel = $(this);
var title = $channel.find('title:first').text();
Perhaps needless to say, there is a div with the id="val_add" which catches the echo..
Instead of finding the title with jQuery I used cUrl to find it within the php page..