We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Ajax data is not defined error

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;
?>
2
Contributors
1
Reply
3 Minutes
Discussion Span
3 Months Ago
Last Updated
7
Views
Question
Answered
code_rum
Junior Poster in Training
50 posts since Feb 2013
Reputation Points: 8
Solved Threads: 8
Skill Endorsements: 3

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

radhakrishna.p
Posting Whiz in Training
263 posts since Nov 2012
Reputation Points: 29
Solved Threads: 59
Skill Endorsements: 10
Question Answered as of 3 Months Ago by radhakrishna.p

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0599 seconds using 2.72MB