Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8805987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:00:16+00:00 2026-06-14T02:00:16+00:00

I have this ajax/jquery code : var headline = $(input#headline).val(); var subheadline = $(textarea#subheadline).val();

  • 0

I have this ajax/jquery code :

var headline = $("input#headline").val();
var subheadline = $("textarea#subheadline").val();
var pics = $("input#pics").val();   
var dataString = 'headline='+ headline + '&subheadline=' + subheadline + '&pics=' + pics;

$(".save-notice").hide();
$.ajax({  
type: "POST",  
url: "web-block/forms/process-001.php",
data: dataString,
success: function() {             
$(".save-notice").show();
$(this).parents(".manage-content-wrap").next(".ribbon-content").fadeIn();
}  
});  

on the other side, I have this HTML form :

<form action="" id="select-block" class="general-form">
<div class="input-wrap">
    <input class="clearme" name="Headline" value="<?php echo $Headline;?>" id="headline"/>
</div>
<div class="input-wrap">
    <textarea class="clearme" name="Sub-Headline" id="subheadline"><?php echo $SubHeadline;?></textarea>
</div>
<label>Bottom Left Image</label>
<div class="up-mask">
    <span class="file-wrapper">
      <input type="file" name="Pics" class="photo" id="pics" />
      <span class="button">
         <span class="default-txt">Upload Photo</span>
      </span>
    </span>
</div><!-- .up-mask -->

<input type="hidden" name="Key" value="<?php echo $Key;?>"/>
<input type="submit" class="submit-btn" value="SAVE" />
<span class="save-notice">Your changed has been saved!</span>
</form>

as you can see process-001.php is the file which process all variables from HTML form. but I have difficulties to ‘catch’ $Headline and $SubHeadline submitted by that form, which actually ‘manipulates’ by Ajax too…

I tried using this code on process-001.php :

$Headline = $_POST['Headline'];
$SubHeadline = $_POST['Sub-Headline'];

but seems that those variables are empty… how to get variables submitted by AJAX correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:00:17+00:00Added an answer on June 14, 2026 at 2:00 am

    headline and Headline are not the same key. Your keys need to match exactly.

    Also, as building the strings by hand can become extremely tricky very quickly, you may want to consider using an object literal or serialize():

    data: {
        'foo': 'bar',
        'baz': [1, 2, 3]
    }
    

    Would have $_POST['foo'] === 'bar' and $_POST['baz'] === array(1, 2, 3)

    You also shouldn’t assume that any kind of inputs exist:

    $headline = (isset($_POST['headline'])) ? $_POST['headline'] : null;
    

    Otherwise you can get index undefined notices.

    Also, since you’re not using any of the options that $.post doesn’t expose, you could just use $.post for shorthand:

    $.post("web-block/forms/process-001.php", {
        data: $("#select-block").serialize(),
        function() {             
            $(".save-notice").show();
            $(this).parents(".manage-content-wrap").next(".ribbon-content").fadeIn();
        }  
    });
    

    Or:

    $.post("web-block/forms/process-001.php", {
        data: {
            Headline: $("#headline").val(), //input#headline is redundant -- getting a node by ID is extremely efficent; getting by tag is not
            'Sub-Headline': $("#subheadline").val()
        },
        function() {             
            $(".save-notice").show();
            $(this).parents(".manage-content-wrap").next(".ribbon-content").fadeIn();
        }  
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
I have this ajax jquery code: var form = document.getElementById('frm'); var data_string = form.serialize();
I have this snippet of code (AJAX) in jQuery. $.get('someScript.php?lat=' + clickedLatLng.lat() + '&lon='
I have this jQuery code: <script type=text/javascript > $(function() { $('#add_comment').bind('submit',function() //$(input[type=submit]).click(function() { var
I have this jQuery code: $.ajax({ type: POST, url: /problems/vote.php, dataType: json, data: dataString,
I have this jquery code: var myarr = [aa,ss,dd]; $.ajax({ url: proces.php, data: arr=+myarr,
I have this Javascript/JQuery code: <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script> <script type=text/javascript> name = $(#name).val(); alert(Name:
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
On my main page I have this jquery code which does an ajax call
I have a jQuery AJAX call with type:'GET' like this: $.ajax({type:'GET',url:'/createUser',data:userId=12345&userName=test, success:function(data){ alert('successful'); }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.