Hi All,

I have a application , which onclick of submit takes content in textarea and do some back end stuff and finally opens a .html in a iframe.

My problem is, the .html in iframe should change on each submit button in coresponding to the content in the textarea.... but its not, can anybody a suggest a solution for this?

           function submit() {
                var textAreaContent = $("#content").val();
                   var content = textAreaContent.substr(textAreaContent.indexOf('\n'),textAreaContent.length);
 alert(content);
                $.ajax({
                    type: 'GET',
                    url: 'submit.php?data='+content+'',
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function(response) {
                        alert("Sucess");
                    },
                    error: function(response) {
                        alert("Error");
                        alert(response);
                    }
                });

 document.getElementById("ChromatinModel").src = "http://dna.engr.latech.edu/~kpc009/ICMGB/ICM/chromatin.html";
            }
        </script>


            <iframe id="ChromatinModel" width="505" height="500" ></iframe>

Thanks,
Priya

I think you should put the content data into the 'data' parameter in the ajax call, instead of adding it to the URL, such as:

url: "submit.php",
data: "{'content':'" + content + "'}",

but it gets a bit tricky with the formatting of the value for the data parameter; the value should be a serialized JSON string, and the contents of a textarea can of course include quote characters etc. I sometimes use a stringify function to serialize an array of data to be submitted, and do something like:

var myParams = {param1: value1, param2: value2};
$.ajax({
  type: 'GET',
  url: 'submit.php',
  contentType: 'application/json',
  data: stringify(myParams),
  dataType: 'json',
  etc...

Depending on the version of jQuery or whatever libraries you are using, or versions of browser you are targetting, the stringify function or other JSON serialisation methods may be available already.