I am making an AJAX request from one page to another webform (*.aspx). I am passing Japanese text as description from ajax and this is working fine in all browsers except in IE. I even added Japanese language (ja-JP) to the browsers languages with an assumption that IE will support it but I failed.
Need some work around for this... Waiting for your help.
Below is my ajax code
$.ajax({
url: urlAssetUpload + uploadVars,
type: 'POST',
processData: false,
contentType: "charset=UTF-8",
data: encodeURIComponent(formDatz)
});
Related
I am trying to pass the value of a textarea to an php page to then be processed and added to a SQL database.
I want the text area to be able to support special characters.
Everything works fine till I put this string in the text area and post it:
JΛ̊KE#2##&($^#%###%))$&#("""
I am getting a 501 Not implemented error.
Now when I paste in certain PHP code into the text area (not to run, purely to save as a string), I get a 403 Forbidden error.
Why does the value of the text area affect the error code?
For now, the paste.php file has no code so that I could try and understand where the error is coming from. I am certain the error is coming from the ajax post. I've looked everywhere online but have not been able to find how to make the string safe to post. encodeURIComponent doesn't seem to work in this case.
Here is the JS for the button press:
var note = $("#note").val();
var dataString = encodeURIComponent(note);
$.ajax({
type: "POST",
url: "php/paste.php",
data: JSON.stringify({
paste: dataString
}),
dataType: 'text',
contentType: "application/json; charset=utf-8",
success: function(msg) {
alert(msg);
console.log(msg)
},
error: function(ts) {
alert(ts.responseText)
}
});
try adding this
Content-Type: application/x-www-form-urlencoded
What was needed was to use this function on the data.
function encode_utf8(s) {
return unescape(encodeURIComponent(s));
}
Change the content type to
ContentType: "application/x-www-form-urlencoded; charset=UTF-8"
and for the kicker, add this to my .htaccess file :
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
I've got an editor that allows editing some text that has to be sent to my backend via Ajax Post request. This works fine so far with the only problem being that when I load the Text from the backend after saving it the encoding seems messed up (line breaks are not interpreted correctly). I tried setting the contentType flag in my Ajax request to contentType: "text/plain;charset=UTF-8" but after this change I'm getting this exception in my springboot controller responsible for the request url:
org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'editorText' is not present
Anyone got an idea on how this flag may mess up the call ? (Before I've just had the flag set to contentType: false).
Complete Ajax call:
$.ajax({
url: "/someUrl",
type: "POST",
data: new FormData($("#uploadForm")[0]),
contentType: "text/plain;charset=UTF-8",
processData: false,
cache: false,
...
});
I have written code that form checks and if all is good passes user input data to ajax so that the database table can be written to. While trying various browsers I am successful at writing to the table with chrome and iexplorer but nothing is written in firefox and no php errors are thrown.
Can anyone see any reason why the following ajax call is not successful with firefox?
$.ajax({
type: "POST",
url:"ajax/ajax_repSub.php",
data: {tDate: tDate, tSpecies: tSpecies, tSqrNum:tSqrNum, tLat:tLat, tLng:tLng, tCond:tCond, tNum:tNum, tHab:tHab, tBehav:tBehav, tReg: tReg, tStage: tStage},
dataType: "text",
cache: "true",
success: function(msg,string,jqXHR){
$("#results").html(msg+string+jqXHR);
}
});
I have a big problem with IE8
I have field TextArea, user write everything use lot of characters ç àèì áéí, show ok in textarea, debug in Javascript and Jquery ok too.
but when I send to MVC controller change characters special for "?"
I tryed in Chrome and FF IE 10 or 11 , its ok, problem is only IE 8
Using Ajax
$.ajax({
type: "POST",
url: "url",
dataType: "json",
data: "{}",
contentType: "application/json; charset=iso-8859-1",
success: function (msg) {
alert(msg);
},
});
In the line "contetType" is possible change character type and send format what you want.
I have this javascript in my page.
function save() {
// submit the dataform
s = document.dataform.action.split('?');
d = s[1]+'&'+$("#dataform").serialize();
$.ajax({
url: s[0],
data: d,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: handleReply
});
}
It is called when I want to submit the form (and handle the reply using AJAX). However although $_SERVER['REQUEST_METHOD'] is indeed "POST" when it arrives at the server, all the data arrives in the $_GET variable! :(
I have screens with more than 2K of data so I have to find how to POST the data using the normal (and unlimited) POST method.
I had a version with the url and data lines as
url: document.dataform.action,
data: new FormData(document.dataform),
This worked superbly with some data arriving from the action in $_GET and the rest from screen fields arriving in $_POST. Then I tested it using IE8 and IE9, which don't support FormData.
Can anyone suggest how I can modify the code to work in IE8 and IE9 and use POST transfer logic.
Thanks