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 6595807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:59:15+00:00 2026-05-25T17:59:15+00:00

I do this ajax request: var response = $.ajax({ url: ‘product/add’, data: $(#formAddNewRow).serialize(), type:

  • 0

I do this ajax request:

 var response = $.ajax({
    url: 'product/add', 
    data: $("#formAddNewRow").serialize(),
    type: "POST",
    success: function() {
    var id = response.responseText;     
                        }            
                      });  

'product/add' is a symfony action that does some stuff. the action’s view is what gets returned, for testing purpose that file looks like this:

<?php

 echo "test";

?>

When I look at response.responseText right after success, I get "test\n". I would have expected just "test".

This is what a Response Header looks like:

Date    Thu, 22 Sep 2011 15:17:45 GMT
Server  Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By    PHP/5.3.5
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma  no-cache
Content-Length  5
Keep-Alive  timeout=5, max=99
Connection  Keep-Alive
Content-Type    text/html; charset=utf-8

Somewhere else I do an ajax request to url: 'product/update', it’s view being exactly the same code (<?php echo "test"; ?>). But in this case response.responseTextequals "test", which is what I expect – there is no \n added.
In that case, a Response Header looks like:

Date    Thu, 22 Sep 2011 15:27:20 GMT
Server  Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By    PHP/5.3.5
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma  no-cache
Content-Length  4
Keep-Alive  timeout=5, max=99
Connection  Keep-Alive
Content-Type    text/html; charset=utf-8 

I have not the slightest idea, why response.responseText whouldn’t be the same in both cases.

Why does a newline character get added to response.responseText?

  • 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-25T17:59:15+00:00Added an answer on May 25, 2026 at 5:59 pm

    I would guess that there is a linefeed character after the final ?>

    Unless I am actually putting PHP inside a HTML page, I always leave off the last ?>. It isn’t necessary, and tends to cause problems like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var request = new Request({ method: 'get', url: 'onlinestatusoutput.html.php', onComplete:function(response) { $('ajax-content').get('tween', {property: 'opacity',
function sendValues() { var str = $(#ryan_m).serialize(); var response = $('input[name=brand[]]:checked').val(); $.ajax({ url: /trying1.php?avoidcache='
I have a jQuery .ajax call: $j.ajax({ type: POST, url: /Services/Cart.asmx/UpdateQuantity, data: data, contentType:
I have this code for doing an ajax request to a webservice: var MyCode
I use this pseudo-class to make Ajax request to server: function RequestManager(url, params, success,
I have ajax request to post data to asmx webservice, how will i post
Consider this code: new Ajax.Request('?service=example', { parameters : {tags : 'exceptions'}, onSuccess : this.dataReceived.bind(this)
I've got this textBox which triggers off an ajax request using jQuery: <asp:TextBox ID=postcodeTextBox
There is currently this Prototype code that does a PUT: new Ajax.Request(someUrl, { method:
How can I modify this: /services/type/single_dwelling/ to this: /ajax/services/single_dwelling/development Currently I have: linkUrl =

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.