Jquery Failing In Electron – JavaScript – SitePoint Forums

[ad_1]

Hello,

I’m doing an ajax call in Electron that only fails sometimes. If I copy and paste the data into the php server file, it works 100% of time. Sadly, this is killing my workflow, and it happens on a few important ajax calls. The error says invalid json, invalid token ‘<’.

Jquery – 3.6.1
Electron – 22.0.0

Ajax:

$.ajax({
url: ‘http://localhost/OtherRealms/php/scripts/update_character_xml_field.php’,
dataType: ‘json’,
type: ‘POST’,
contentType: ‘application/json; charset=utf-8’,
data: pipSkillData,
success: function( data, textStatus, jQxhr ){
//console.log(data);
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
}
// End updata skill
});
// end fetch skill tier
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
}
});

The server code shouldn’t be needed. I’ll just share what I’ve placed at the top for data.

$data[‘characterToken’] = ‘2205d49f4165e46eb3b65e32a1fa02d3’;
$data[‘pipType’] = ‘pip skill’;
$data[‘skillName’] = “magic”;
$data[‘skillType’] = “skill”;
$data[‘tier’] = “II”;
$data[‘userSerial’] = “9e0b6bf61339998735ff478db747ba04”;
$data[‘userToken’] =“58e4d9a44dc47b84d4a2db84e9188cdc” ;

Here’s a couple of images
code-section
post-data

If this can’t be solved is there a work around? Would vanilla Ajax calls be better?

frontpageads:

The error says invalid json, invalid token ‘<’.

That’s probably the start of a php error from the server-side code. What does the full response show in the browser’s developer tools network tab?

…..

[ad_2]

Read More

About the author

Jquery Failing In Electron – JavaScript – SitePoint Forums – webhostingreviewsite.com