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

  • SEARCH
  • Home
  • 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 7082261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:01:34+00:00 2026-05-28T07:01:34+00:00

This is being sent via Ajax. Here’s the JS: $.ajax({ url: objCommon.ajax, type: ‘POST’,

  • 0

This is being sent via Ajax. Here’s the JS:

$.ajax({
    url: objCommon.ajax,
    type: 'POST',
    data: {type:'feedback', msg:$('.commonsFeedbackDiv').text(), url:window.location.href},
    success: function(data){
        console.log(data);
        if(data.search('ajaxError') === -1){
            console.log('sent');
        }else if(data.search('msg')){
            alert('Please enter a message.');
        }
    }
});

And the PHP that processes the request:

global $user;
echo $_POST['msg'];
echo $_POST['url'];
if(isset($_POST['msg']) && $_POST['msg'] !== ''){
    mail('commons@example.com', 'Commons Feedback', 'url: ' + $_POST['url'] + $_POST['msg'], 'From: ' . $user->mail);
}else{
    echo 'ajaxError - no msg';
}

You can see in the success() callback function that I’m logging the response to the console, and this response is made up of the two echo statements near the beginning of the PHP code. The string that ends up in the console is correct; it contains both the message and the URL. However, the actual email I receive simply contains the number 0 in the content.

Any idea why?

  • 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-05-28T07:01:34+00:00Added an answer on May 28, 2026 at 7:01 am

    The operator to concatenate strings in php is . not +. The plus sign performs numerical addition, which in turn converts strings into the value 0.

    Therefore you need to change

    'url: ' + $_POST['url'] + $_POST['msg']
    

    to

    'url: ' . $_POST['url'] . $_POST['msg']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to post data via ajax, this is my info: var jsondata =
When I submit the form, the data is not being sent in the post
Hey, no idea why this sint working, but the message is being sent as
I have various emails being sent out via PHP mail. The problem is, for
I'm trying to send an email via some C# ASP.NET code. This is being
Here is my code that sends a form via AJAX and then is meant
I have the following php object(??? new to this). It is being sent through
I'd like to add Unicode characters to plain text email being sent via SMTP.
I am wanting to use the AJAX function via jQuery to return some data
I've got data being sent from a client side which is sending it like

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.