AJAX中的POST方法

i am passing variables using post method but not able to pass complete value of variables .

Here is script:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

    var problem_code = $("#problem_code").val();
    var code = $("#code").val();
    var lang = $("#lang").val();
    $.ajax({
        type: "POST",
        url: "ajax.php",
        cache:false,
        data : {problem_code:problem_code,code:code,lang:lang},
        success: function(html)
        {
            //alert("ajax response returned.. ");
            //console.log(html);
            $(".show-result").empty();
            $(".show-result").append('<br>' + html);
        }
    })

});
</script>

And here is the rest part

<?php 
$code=stripcslashes($_POST['code']);
$lang=stripcslashes($_POST['lang']);
?>

Getting $code and $lang value pass by another file "Submit.php"

Now using input hidden fields

    <input type="hidden" id="problem_code" name="problem_code" value=<?php echo $problem_code;?> >
<input type="hidden" id="code" name="code" value=<?php echo ($code);?> >
<input type="hidden" id="lang" name="lang" value=<?php echo $lang;?> >

but while passing $code value using hidden fields it is showing unexpected behaviour.

here is view-source example while running above scripts

<input type="hidden" id="problem_code" name="problem_code" value=LUCPAL >
<input type="hidden" id="code" name="code" value=#include <iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main() {
int t;
scanf("%d",&t);
while(t--)
{
    long long int A,B,copy,sum=0;
    scanf("%lld %lld",&A,&B);
    copy=B;
    int digit=0;
    while(copy>0)
    {
        digit++;
        copy=copy/10;
    }
    while(digit--)
    {
        sum=10*sum+9;
    }
    long long int sum2=sum/2,diffA,diffB;
    if(sum2>=A && sum2<=B)
    {
        printf("%lld
",(sum2)*(sum2+1));
    }
    else
    {
        diffA=fabs(sum2-A);
        diffB=fabs(sum2-B);
        if(diffA<diffB)
            printf("%lld
   ",A*(sum-A));
        else
        printf("%lld
    ",B*(sum-B));

    }
}
// your code goes here
return 0;
}
>

<input type="hidden" id="lang" name="lang" value=11 >
`
    printf("%lld
",A*(sum-A) become  printf("%lld

    ",A*(sum-A));

and only '#include' pass in ajax.php from all code.

replace all your < and > with &gt; and &lt; (in the value = "..." section anyways) The post request will think your are closing the tag incorrectly and cut off at the first > (Less than) symbol. EDIT: like this:

<input type="hidden" id="problem_code" name="problem_code" value=LUCPAL >
<input type="hidden" id="code" name="code" value='#include &gt;iostream&lt;
#include&gt;stdio.h&lt;
#include&gt;math.h&lt;
using namespace std;
int main() {
int t;
scanf("%d",&t);
while(t--)
{
    long long int A,B,copy,sum=0;
    scanf("%lld %lld",&A,&B);
    copy=B;
    int digit=0;
    while(copy&lt;0)
    {
        digit++;
        copy=copy/10;
    }
    while(digit--)
    {
        sum=10*sum+9;
    }
    long long int sum2=sum/2,diffA,diffB;
    if(sum2&lt;=A && sum2&gt;=B)
    {
        printf("%lld
",(sum2)*(sum2+1));
    }
    else
    {
        diffA=fabs(sum2-A);
        diffB=fabs(sum2-B);
        if(diffA&gt;diffB)
            printf("%lld
   ",A*(sum-A));
        else
        printf("%lld
    ",B*(sum-B));

    }
}
// your code goes here
return 0;
}'
>

<input type="hidden" id="lang" name="lang" value=11 >
`
    printf("%lld
",A*(sum-A) become  printf("%lld

    ",A*(sum-A));