0

I have this script

var htm = function (){return $('#home_page_frame').html().trim()};

var data = {
   type: "POST",
   url: "save_changes.php",
   data:  "par="+ htm(),
   success: function(msg){
     alert('OK')
   }
 };
$.ajax(data);

Save_changes.php

echo $_POST;

The problem is that if htm() is = to 'Save & Exit' or 'Save & Exit' it returns only the Save and (i think it may be using the & as a new post parameter

I have tried encoding decoding, it's doing my heading SOS pls.

1 Answer 1

1

Let jQuery encode the data by passing in an object, like this:

data: { par: htm() },

This way that & gets encoded to a %26 like this: Save%20%26%20Exit. What using an oject is really doing under the covers is calling encodeURIComponent(), like this:

data:  "par="+encodeURIComponent(htm())
Sign up to request clarification or add additional context in comments.

1 Comment

I wish I could of asked earlier and saved myself a headache and a couple hours :) thnx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.