1,105,644 Community Members

Ajax data is not defined error

Member Avatar
code_rum
Junior Poster in Training
80 posts since Feb 2013
Reputation Points: 8 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 6 [?]
 
0
 

Hi,

Below is my ajax code along with html and php code.
I am getting an error "title is not defined"..

Ajax
------
function callAjax() {
    $.ajax ({
        type: "POST",
        url: "get.php",
        data: "title=" + title, 
        success: function(msg) {
            alert(msg);
        },
        error: function(msg){ alert(msg); },

    });
}

HTML
------
<form method="post" onsubmit="callAjax();">
    <div class=><label for="title">Title:</label><input type="text" name="title" /></div><br/>
<input type="submit" value="submit"></form>';

get.php
--------
<?php 
$title = $_POST['title'];
echo $title;
?>
Member Avatar
radhakrishna.p
Posting Whiz in Training
281 posts since Nov 2012
Reputation Points: 29 [?]
Q&As Helped to Solve: 64 [?]
Skill Endorsements: 11 [?]
 
0
 

please specify the problem clearly

i could find the variable name 'title' at php file,ajax and html too

where you are getting from?

at line 7 how you get the value of title? that might be the problem i think

happy coding

Question Answered as of 1 Year Ago by radhakrishna.p
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: