Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
chrome.runtime.sendMessage error “Message length exceeded”
Mehul Prajapati
6y
185
1
Reply
When i am sending big size of json object from content.js to background.js usingchrome.runtime.sendMessage then showing error like
Error is : Uncaught Error: Message length exceeded maximum allowed length.
Content.js
var
ServerPath =
"http://localhost:62513/api/account"
;
chrome.runtime.sendMessage({
method:
'POST'
,
action:
'xhttp'
,
url: ServerPath +
"/rapdata"
,
data: JSON.stringify({ data: data, fileName: fileName })
},
function
(responseText) {
//alert(responseText);
console.log(
"response of call saverapdata method"
);
/*Callback function to deal with the response*/
});
Background.js
chrome.runtime.onMessage.addListener(
function
(request, sender, callback) {
console.log(
"background js onMessage call."
);
var
resp =
"done"
;
if
(request.action ==
"xhttp"
) {
debugger
;
//alert(request.data);url: ServerPath + "/rapdata",
var
ServerPath =
"http://localhost:62513/api/account"
;
$.ajax({
type:
"POST"
,
url: request.url,
data: request.data,
contentType:
"application/json; charset=utf-8"
,
dataType:
"json"
,
success:
function
(data) {
debugger
;
console.log(data);
//alert("Data: " + data);
},
failure:
function
(response) {
debugger
;
console.log(response);
///alert(response.d);
}
});
return
true
;
// prevents the callback from being called too early on return
}
});
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
connect html,javascript or css
Here i am getting output as undefined, please tell me why