Javascript runtime error: 'processPartInput' is undefined - javascript

I am trying to retrieve data from a controller. This is a new twist on my Json error. I added a function to the index.cshtml page and I try to add code to get the information from the controller. I added a basic code to write a string to the textbox (all local) and that worked. When I tried to call from the controller it doesn't matter what the code is I get this error:
(source: mousecreations.com)
I have tried the following with the same error. Probably some other combinations that I have found in my search.
$.getJSON(#Url.Action("GetIPAddress","getipaddress"),
$.get(......)
$.ajax(......)
The entire function
function processgetip(event)
{
// Within this function, make an AJAX call to get the IP Address
$.getJSON(#Url.Action("GetIPAddress","getipaddress"), function (ip) {
// When this call is done, your IP should be stored in 'ip', so
// You can use it how you would like
// Example: Setting a TextBox with ID "YourElement" to your returned IP Address
$("#facility").val(ip);
});
}
This error is different than any of the others so what in that process event would cause the other processes to be undefined?

Related

Why does Stripe's handleCardPayment not run in my Javascript function?

I am trying to use Stripes handleCardPayment to process a charge following a payment intent. I can't get the handleCardPayment function to run inside another Javascript function.
I have tried to debug my code step by step. The Javascript function runs and will print out an alert to the window.
The Javascript variables I set at the top of the function also get set.
The handleCardPayment() function however does not seem to run?
I have attempted a try/catch to see if I can catch the error coming from the request but nothing is logged.
I am a little stumped as to where the issue is with this? although I suspect it might be something basic that I am missing on calling the stripe function correctly.
function completePayment() {
// Assign client secret from PHP session variable
var clientSecret = "<?php echo $_SESSION['c_secret'] ?>";
try {
stripe.handleCardPayment(
clientSecret, cardElement, {
source_data: {
owner: {email: "<?php echo $_SESSION['m_usr_email'] ?>"}
}
}
).then(function(result) {
if (result.error) {
alert("Error in payment");
} else {
alert("Success in payment");
}
});
}
catch(error) {
console.log(error.message);
}
}
My payment intent is created on a separate PHP page. This works correctly and a payment intent is created in stripe with an associated client secret.
How the app currently functions:
User presses 'Subscribe' button.
Ajax request runs and POSTS to a separate PHP file
PHP file creates the payment intent and saves the client secret in a PHP SESSION variable
Ajax 'Complete function()' then calls 'completePayment();'
Javascript function 'completePayment();' is located just before the closing tag at the bottom of the page.
Debugging 'completePayment()' shows that the function does execute following the Ajax 'Complete function()' call.
stripe.HandleCardPayment fails to do anything.
cardElement is a global Javascript variable set when the card element is created (this is created on initial page load).
I have debugged both PHP SESSION variables and confirm that they have both been set with the correct information prior to using them in the handleCardPayment function.
Any suggestions on what I am doing wrong here?
I had same problem. It looks like the function it does not execute becouse the console logs does not appear but after searching I saw that I missing $intent->client_secret, before that, the js console not show me anything and I had to call only the function stripe.handleCardPayment without any code extra then the cosole show me $intent->client_secret It was undefined.
I don't speak english very well I hope that It will serve somebody

undefined result javascript

I have a simple javascript code, that validate when you write a order number and generates tags with javascript(with bootstrap-tagsinput js):
var order = $('#order_number').val();
if ($.inArray(order, $('#input_order_tags').val()) >= 0) {
$('#input_order_tags').tagsinput('add', order);
return;
}
var params = {
email: email,
order_code: order
}
AjaxServices.validateOrderNumberByEmail(params, function(error, result) {
if (error)
alert(error);
else
$('#input_order_tags').tagsinput('add', result.order);
});
This works fine but, every time trigger the error message when send a order number:
Console chrome debug:
How I can avoid the error of alert?
This is not a javascript issue. Server-side in you application you use order_code in one of the calls which returns the error message you see in the ajax call. Debug the offending call server-side, see which call returns that error and adjust your code so it works properly.
There might be two possibilities
client side issue ( javascript error) if so, its because the field order_number is disabled field.
as mentioned in this link
undefined index on javascript dynamic variables when passing to php form
If so, remove that disabled and use read-only and check if it works, without any error.
Server side issue( ajax call) if so, server side code which performs on call of that ajax call is causing that issue.

"Expression does not produce a value" in javascript, vb.net

In the Create View of the "Deal" model, I've defined a javascript function that creates a new object in a List Property when clicking a button.
I get the error "expression does not produce a value". I'm not expecting a value, I only need to create a new empty object in the list, so I don't understand this error.
javascript in my view, the line that adds the new Period to the list throws the error:
<script type="text/javascript">
function addRow() {
#Model.Periods.Add(New DealPeriod());
...
}
</script>
"Deal" Model:
Public MustInherit Class Deal
...
<Display(name:="Periodos")>
Public Property Periods As New List(Of DealPeriod)
There are two issues here - to cover the issue in the question "expression does not produce a value":
The #symbol here means "output the result of the following to the http response stream".
As List.Add() returns void, there is nothing to send to the response stream, so it gives you that error message.
Put another way, the # needs a value and List.Add() does not generate a value.
The second issue is that it appears you are mixing server-side execute with client-side execution (note I don't say server-side/client-side code, that's allowed in a similar way to how you have it). It appears you want to add a new "DealPeriod" when "addRow" is called - that's simply not how it works. The VB.Net code runs on the server and the javascript code runs on the client, in the browser. They are not linked together.
There are ways to link them such as an ajax call or signalr.
You are expecting #Model.Periods.Add(New DealPeriod()); to run when that javascript function is called, but that is not what is happening. The inline VB code is run server-side before sending HTML to the client.
With your webpage open, view source of the page and observe the code that gets rendered in that javascript function. You will not see that line of code.
What you want to do is make an ajax call to a controller that will perform the logic you want.

Call to $.post() Jquery not passing parameters successfully

/**
* Created by quantumveil on 2/10/15.
*/
$(document).ready(function(){
$('a').on('click',function(){
//$href=$(this).attr('href');
//console.log($href);
var $convoid=$(this).attr('id');
console.log($convoid);
//$('#convoarea').load($href);
$.get('inbox.php',{convoid:$convoid},function(data){$('#convoarea').html(data);//the callback sets whati t had to
//now add the on click handler to send button
$('#send').on('click',function(){
var $msgbody=$('#sendbody').val();
console.log($msgbody);
///now what i have to do is sent this $msgbody to the inbox.php thru get k
$.post('inbox.php',{sendbody:$msgbody,convoid:$convoid},function(data){
$('#sendbody').before(data);
console.log('here'+$msgbody);
});//the callback function will append it to other messages :3
return false;
});
}//callback ends hre
);
return false;
});
//for send button
});
Hi. I'm trying to code a social networking site and I want the inbox to be responsive and dynamic. I've recently started learning Jquery for the purpose being. I've googled this before and found no help and so it brings me here on this community. The above Javascript/Jquery code is supposed to pass some post parameters when the SEND button is clicked. Another file, inbox.php, is to receive those and work appropriately. Now here's what bugs me. The callback function to $.post() is executed, so I'm assuming the parameters are being passed to inbox.php. But when I try accessing them in inbox.php using following line
if($msgbody=get_post('sendbody')&&$convoid=get_post('convoid'))
I only receive a value of 1 and not the message's actual body. Here's how the function get_post is defined
function get_post($var1){
if(isset($_POST[$var1])){$var=$_POST[$var1];
return filter($var);}
else return 0;
}
I've tried accessing them directly through $_POST['sendbody'] but an error of undefined index is being generated. Any help will be highly appreciated. (PS the other call to .get() in the beginning of this js file is passing the parameters so there's nothing wrong with file paths)
EDIT: It's fixed but I want an explanation. All I did was in the inbox.php changed the first line which was
if($msgbody=get_post('sendbody')
to
if(isset($_POST['sendbody'])$msgbody=$_POST['sendbody']
Now all I can wonder is if it has something to do with filter() function in the definition of my get_post() function. Anybody?

Why am I getting this Internal Server Error in the Laravel Framework?

I have come across a situation that doesn't make much sense to me. Just as some background information, I'm using the Laravel framework. The page in question calls a query when the page is requested using Laravel's '->with('var', $array)' syntax. This query (which I will post later) works perfectly fine on page load, and successfully inserts dummy data I fed it.
I call this same query via an Ajax $.post using jQuery, on click of a button. However, when I do this $.post and call this query, I get an Internal Server Error every time. Everything is exactly the same, information passed included; the only difference seems to be whether or not it is called on page load or via the $.post.
Here is the error:
Below is the code that performs the query on page load:
routes.php sends the HTTP get request to a file called AppController.php
routes.php
AppController.php
The page is then made with the following array acquired from DeviceCheckoutController.php
Which then goes to DeviceCheckout.php
I am able to echo $test on the page, and it returns the ID of a new row every time the page is reloaded (which obviously mean the 'insertGetId' query worked). However, I hooked this query up to the page load just to test. What I really want to happen is on click of a button. Here is the code for that:
$("#checkoutFormbox").on('click', '#checkoutButton', function() {
var checkoutInformation = Object();
var accessories = [];
var counter = 0;
var deviceName = checkoutDeviceTable.cell(0, 0).data();
$(".accessoryCheckbox").each(function() {
//add accessory ID's to this list of only accessories selected to be checked out
if($(this).val() == "1")
{
accessories[counter] = $(this).data('id') + " ";
}
counter++;
});
checkoutInformation['deviceID'] = $(".removeButton").val(); //deviceID was previously stored in the remove button's value when the add button was clicked
checkoutInformation['outBy'] = '';
checkoutInformation['outNotes'] = $("#checkOutDeviceNotes").val();
checkoutInformation['idOfAccessories'] = 2;
checkoutInformation['dueDate'] = $("#dueDate").val();
if($("#studentIdButton").hasClass('active'))
{
checkoutInformation['renterID'] = 0;
checkoutInformation['emplid'] = 1778884;
console.log(checkoutInformation);
$.post("http://xxx.xxx.xxx.xxx/testing/public/apps/devicecheckout-checkoutdevices", {type: "checkoutDeviceForStudent", checkoutInformation: checkoutInformation}, function(returnedData) {
alert(returnedData);
});
}
});
Which is also then routed to AppController.php, specifically to the 'checkoutDeviceForStudent' part of the switch statement:
And then back to that query that is shown previously in DeviceCheckout.php
Finally, here is my DB structure for reference:
Any explanation as for why this would be happening? Also, any Laravel or other general best practice tips would be greatly appreciated as I'm inexperienced in usage of this framework and programming overall.
Sorry for such a long post, I hope there is enough information to diagnose this problem. Let me know if I need to include anything else.
Edit: Included picture of error at the top of the page.
Everything is exactly the same, information passed included
No, it isn't. If it was exactly the same you wouldn't be getting the error you're getting.
These sorts of issues are too difficult to solve by taking guesses at what the problem might be. You need to
Setup your system so Laravel's logging errors to the laravel.log file
Setup you PHP system so errors Laravel can't handled are logged to your webserver's error log (and/or PHP's error log)
Put Laravel in debug mode so errors are output the the screen, and the view the output of your ajax request via Firebug or Chrome
Once you have the actual PHP error it's usually pretty easy to see what's different about the request you think is the same, and address the issue.
I found a resolution to my problem after some advice from a friend; much easier than I anticipated and much easier than any solution that has been offered to me here or other places.
Essentially, what I needed to do was place a try, catch clause in my model function, and then if an exception is encountered I store that in a variable, return it, and use console.log() to view the exception. Here is an example to emulate my point:
public function getUserFullname($userID)
{
try
{
$myResult = DB::connection('myDatabase')->table('TheCoolestTable')->select('fullName')->where('userID', '=', $userID)->get();
return $myResult;
}
catch(Exception $e)
{
$errorMessage = 'Caught exception: ' . $e->getMessage();
return $errorMessage;
}
}
And then on the View (or wherever your model function returns to), simply console.log() the output of your POST. This will display the results of the successful query, or the results of the Exception if it encountered one as opposed to an unhelpful Internal Server Error 500 message.

Categories

Resources