Client side to server side calls - asp.net-mvc-3

I want to change the list of available values in a dropdown depending on the value selected in another dropdown and depending on values of certain fields in the model. I want to use JQuery to do this. The only hard part is checking the values in the model. I have been informed that I can do this using Ajax. Does anyone have any idea how I will approach doing this?

AJAX is indeed the technology your looking for. It is used to sent an asynchronous request from the client browser to the server.
jQuery has an ajax function that you can use to start such a request. In your controller you can have a regular method tagged with the [HttpPostAttribute] to respond to your AJAX request.
Most of the time you will return a JSON result from your Controller to your view. Think of JSON as something similar to XML but easier to work with from a browser. The browser will receive the JSON and can then parse the results to do something like showing a message or replacing some HTML in the browser.
Here you can find a nice example of how to use it all together.

Related

Is it better to retrieve data through AJAX or returning it alongside view from Controller (Laravel)?

So the scenario is getting data we need from controller and using it in our view. But there are two options, you can have either this line in your "show" method:
UserController#show
return view('webpage');
And in the 'webpage' you can send an Ajax request to UserController#fetch and get that data. Or you can get the data from database in UserController#show and then send it alongside view like this:
UserController#show
return view('store', compact('store'));
But which is the more efficient and secure way of doing this?
It really depends on what you're doing, if the data you're requesting and the process you're running takes a lot of time or in a future it would, ajax is the way to go, but if process is short and the requested data from your model is small, then you can request it on the same method that returns your view and send the data to it.

Is Jmeter allow to select the option/value from the dropdown list

In My application which I am testing there is a drop down and I have to select the option/value from the list, After selection the value there is a text field which get auto populated. So can we do the same in Jmeter.
Please share the experience if any body has done.
Thanks in advance!
This will be quite difficult.
Selecting the value from the dropdown list is easy. But then your application probably makes an AJAX request to the server to populate the other values. So you would have to :
set up a separate HTTP Request which simulates your AJAX request
parse the HTTP response for the variables you need
save them into jMeter variables
use those to populate your next page request (the form submit)
A much easier way is to use some test data which you already know, and just submit your form with those fields hardcoded into jMeter.

Is Ajax with JSON or Ajax with dojo are same

I am new in Ajax . Want to use Ajax with Json . I am searching the tutorial for this and i find this.
I want to ask is i am in right direction ?
Is both things are same Ajax with Json and Ajax with dojo?
Not the same
Ajax is a technology that send request and accept data asynchronously(do not need to reload page).
You can use JSON or XML to send the data or just use the string.
When you do the Ajax request, any data type(like array, object, number..) except string will lost their data type and become string, so If you want to reserve their type, you must use data transmit format like JSON and XML.
Dojo just a library which have easier method for doing Ajax. You also can use jQuery, Angular,..Whatever even JavaScript native XMLHttpRequest.

Quick AJAX / JSON security question

In a form I have I want to be able to check whether the intended email address or username is unique as part of the validation process
I have created a JSON file with PHP from database data to work with JavaScript validation but the problem is that anybody can see the JSON file
Is there a way around this and still be able to use this method?
In short, no.
Why don't you just create an ajax function that takes in the email address and returns a boolean indicating whether it's unique by querying the database? JQuery has great AJAX capabilities: http://api.jquery.com/category/ajax/

Is it possible to send a form and a html request with same Event by Mootools?

$('submitbutton').addEvent( 'submit', function(e){
e.stop();
$('fuss').send();
req2.send();
});
trying to get this working but not sure if it is possible and had no success so far.
Mootools docs doesnt helped me either.
Will the multiple usage of .send() work?
Do i have to specify the data beeing send for the html request or does it take automatical the data beeing send by the form ?
It's in the documentation: http://mootools.net/docs/core/Request/Request#Element:send
This shorthand method will do a request using the post-processed data from all of the fields.
You can do as many requests in a specific event as you wish, as long as they're all asynchronous.
In your specific example it would seem you want to do two requests using two different methods, one with setting up a new Request class manually and the second doing it via the Element Method.
Based on your last comment, I wrote a little example in jsFiddle.
Basically I think you don't need two request for your goal. Just override onRequest method to update the html.

Resources