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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:29:49+00:00 2026-05-26T08:29:49+00:00

i use ajax for my codeeditor. So the POST contains lot of coding-syntax to

  • 0

i use ajax for my codeeditor. So the POST contains lot of coding-syntax to handle :

$.ajax({  
  type: "POST",  
  url: "process.php",  
  data: dataString,  
  success: function() {  
    $('#messagebox').html("<div id='message'>hero!</div>");  
  }  
});  

datastring is the val() i pull from a textarea, here it is. yes its random code from a file which get edited in the textarea:

<?php
defined('_JEXEC') or die;

// Import library dependencies
jimport('google.api.facebook');

class smartmech extends GmailApiFb
{
    function __construct(&$subject, $config)
    {
        parent::__construct($subject, $config);

        // define language
        $this->loadLanguage();
    }
?>

This is the process.php

            $code = $_POST['code'];             
            $myFile = "testFile.php";
            $fh = fopen($myFile, 'w') or die("can't open file");
            fwrite($fh, $code);
            fclose($fh);

THE RESULT is that the file gets created and saved like this:

<?php
defined('_JEXEC') or die;

// Import library dependencies
jimport('google.api.facebook');

class smartmech extends GmailApiFb
{
    function __construct( 

so it stops at the first “&”. i have no clue why.

Firebug -> Console analyses the post as completely sent, this is why i assume i have to en-/ or decode the ajax before sending.

Any hint is highly appreciated.

Thanks guys for your valuable time

EDIT:
Solution

after further examing the POST from firebug, is saw the newline before starting with the value. (code is the key,

code=   
<?php

So i tried to use the mapping instead of a querystring:

  data: {code: kode}, //dataString, 

this was the difference which makes the code working like a charm.
for completeness to make sense

var kode = editor.getValue();
var dataString = 'code='+kode; 

getValue() is a custom function to get the val() from an element.

Anyone knows why this difference?

  • 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-26T08:29:49+00:00Added an answer on May 26, 2026 at 8:29 am

    I’d be interested in seeing the actual post; particularly, if the parameters are being sent correctly. “data” should be either a serialized set of key:value pairs in the form of a query string (myvar=foo&myothervar=bar) or it can be a map ( { myvar: "foo", myothervar: "bar" } ). If you are just grabbing a string from .val() like “foo” and trying to pass it, it might be poorly-formed upon sending. In other words, if you are grabbing “foo”, it might be trying to send “?foo=” instead of “?myvar=foo“.

    I have to admit, that’s a guess; I’m not in a good environment for testing AJAX right now.

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

Sidebar

Related Questions

I use Ajax (jQuery) and the POST method to update data in the database.
How do i use ajax to send POST requests to the server instead of
I have many forms that use AJAX (w/ jQuery) for validation and data submission.
A form, I use AJAX to transfer the data. The AJAX is triggered by
I'm trying to use Ajax to call a PHP script to write to two
I'm trying to use ajax to make multiple simultaneous requests to a php script,
I use Ajax to kick off a PHP script that can take a few
I want to use AJAX to process a simple login form. I thought it'd
How can I use AJAX to run a PHP file when the page is
I use AJAX controls a lot - AJAX update panels, AJAX-enabled grids, etc. (mostly

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.