Welcome Guest, Not a member yet? Register   Sign In
I unable to pass lot of characters in ajax query string.
#1

[eluser]Mari[/eluser]
Hi dudes ,
I used the following JS script for store the form values in db through the AJAX.It's worked correctly but when I entered lot of charecters in textbox which is in my form this script was not working.Please help me to solve the issue.
Code:
$(function() {
$(".submit").click(function() {
var name = $("#name").val();
var title = $("#title").val();
var content = $("#content").val();
var dataString = 'name ='+ name +'&title; ='+title+'&content; ='+content;

$.ajax({
type: "POST",
url: "join.php",
data: dataString,
success: function(){
$('.success').fadeIn(200).show();
$('.error').fadeOut(200).hide();
});
});
});
});

I got the error, when passed more than 1000 characters in "content" variable.

Help me to solve the issue.
#2

[eluser]LuckyFella73[/eluser]
Hi Mari,

you better send your values as post values like this:
Code:
$(function() {
$(".submit").click(function() {
  var frm_name = $("#name").val();
  var frm_title = $("#title").val();
  var frm_content = $("#content").val();
  //var dataString = 'name ='+ name +'&title; ='+title+'&content; ='+content;

  $.ajax({
   type: "POST",
   url: "join.php",
   data: { name: frm_name, title: frm_title, content: frm_content },
   success: function(){
    $('.success').fadeIn(200).show();
    $('.error').fadeOut(200).hide();
   });
  });
});
});

In your controller get the values like:
Code:
$name = $this->input->post('name');
$title = $this->input->post('title');
$content = $this->input->post('content');

Does the form data reach your "join" controller the way you have it?
Usually you have to put the base_url() here..
#3

[eluser]xeroblast[/eluser]
maximum characters of string in javascript is 268435455.. more than that, the script wont run, firebug gives "allocation size overflow"..
#4

[eluser]Mari[/eluser]
Hi LuckyFella73 thanks for your reply It's really worked for me.....Thanks a lot...




Theme © iAndrew 2016 - Forum software by © MyBB